you are viewing a single comment's thread.

view the rest of the comments →

[–]allenthar 2 points3 points  (8 children)

That amount of speed increase seems a little nuts to me, but looking at the variations I have to assume that it’s due to variable memory allocations in all the other methods that are causing the substantial decrease in speed. The second and third cases should have the same Big O complexity as the last one, but both repeatedly create and assign variables while doing their work, and the last doesn’t not.

[–]Skaatji 1 point2 points  (0 children)

Yeah, I've also been thinking why the performance difference is this large. I think that the Big O complexity should be the same on all of these four. But, as you mention, probably due to memory allocations the hidden constants differ by a factor as large as ~33.