﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Vadim Kantorov commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>I get your point. Though I still don't agree.
  
  
Anyway, you use big o notation to discuss the complexity of the algorithm. N in the O(N^3 + N) barely adds anything to the overall time complexity.
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment12</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment12</guid><pubDate>Thu, 24 Dec 2009 11:29:57 GMT</pubDate></item><item><title>Paul Hatcher commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>We have..
  
  
1. Outer loop - O(N)
  
1.a. Linq query - O(N)
  
1.b  OrderedCollection.Add - O(N)
  
2. StatementChanged - O(N)
  
  
Now the Linq query and the OrderCollection.Add are in the scope of the outer loop, so we have O(N*2N+N) which is O(N^2)
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment11</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment11</guid><pubDate>Thu, 24 Dec 2009 09:43:11 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>Vadim,
  
O(N^3 + N) express what is going on better than just N^3. Note the comment in the end of the post.
  
  
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment10</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment10</guid><pubDate>Wed, 23 Dec 2009 21:10:46 GMT</pubDate></item><item><title>Rafal commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>Yep, it's not O(N^3) but O(N^2) like Manu said. If it were O(N^3) the program would probably take 50 years to process 50 000 statements.
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment9</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment9</guid><pubDate>Wed, 23 Dec 2009 19:35:32 GMT</pubDate></item><item><title>tobi commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>arent people reading your post ayende? three comments about n^2 already...
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment8</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment8</guid><pubDate>Wed, 23 Dec 2009 19:26:01 GMT</pubDate></item><item><title>Manu commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>I also think it's O(N^2). The LINQ query takes O(N) and the unfilteredStatements.Add statements takes O(N). This sums up to O(N + N) and not O(N * N) within the foreach loop.
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment7</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment7</guid><pubDate>Wed, 23 Dec 2009 18:30:36 GMT</pubDate></item><item><title>Vadim Kantorov commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>Just my fifty cents.
  
  
Anyway, why haven't you simply written O(N^3) instead of O(N^3  + N) and O(N) instead of O(N + N)?
  
  
For me it's confusing to see odd O(N^3 + N) instead of O(N^3). And even more confusing to see this in the post title...
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment6</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment6</guid><pubDate>Wed, 23 Dec 2009 18:02:27 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>Mike,
  
As I said in the post, the collection changed event is making an O(N) operation every time it is invoked.
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment5</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment5</guid><pubDate>Wed, 23 Dec 2009 14:39:38 GMT</pubDate></item><item><title>Mike G commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>I think Sebantian is right, this is O(N^2). 
  
  
Unless the CollectionChangedEvent is performing an O(N) operation and for each value of N the subscriber is performing, everything in unfilteredStatements is O(N), not O(N^2).
  
  
It is O(N), the for loop,  operating on N+N+N, the three O(N) statements, which comes out to O(N^2). 
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment4</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment4</guid><pubDate>Wed, 23 Dec 2009 14:27:59 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>Sebastian,
  
Note the next statement, unflitedStaetments is firing a CollectionChanged event that has a subscriber that does another O(N) operation
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment3</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment3</guid><pubDate>Wed, 23 Dec 2009 13:00:08 GMT</pubDate></item><item><title>Sebastian Ullrich commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>&gt;&gt; At first glance, it looks like O(N*N), right?
  
At second glance, it still does to me.
  
Your loop body is a sequence of two O(n) operations, summing to O(n). So we have a O(n²) loop followed by a O(n) operation, that's O(n²+n) = O(n²).
  
  
...whatever - another great example of real world performance improvements!
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment2</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment2</guid><pubDate>Wed, 23 Dec 2009 12:47:08 GMT</pubDate></item><item><title>Richard Dingwall commented on UberProf performance improvements, or: when O(N^3 + N) is not fast enough</title><description>Can't wait to see these performance improvements in action myself. Keep up the good work!
</description><link>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment1</link><guid>http://ayende.com/4335/uberprof-performance-improvements-or-when-o-n-3-n-is-not-fast-enough#comment1</guid><pubDate>Wed, 23 Dec 2009 11:09:23 GMT</pubDate></item></channel></rss>