Skip to main content

Timeline for answer to Performance testing functions for wrapping an index by Saeed

Current License: CC BY-SA 2.5

Post Revisions

12 events
when toggle format what by license comment
Feb 5, 2011 at 17:57 vote accept Kiril
Feb 5, 2011 at 11:55 comment added Saeed @Lirik, see EDIT 2 in my answer. I think I have a good explanation for why your code gives different results than mine.
Feb 5, 2011 at 11:50 history edited Saeed CC BY-SA 2.5
Updated answer based on latest comments; added 49 characters in body
Feb 5, 2011 at 8:43 comment added Saeed @Lirik, I updated my answer. Updating the index in the loop shouldn't matter since we're doing it the same for all operation types, but it does add a lot of noise to do two % operations in a perf test that's testing the effects of %. I updated the test to just do a simple iteration over start indices, and always use a fixed end index. This still gives the same kind of results, though plain and mask tend to be closer to each other now, while mod is relatively more expensive.
Feb 5, 2011 at 8:40 history edited Saeed CC BY-SA 2.5
Updated function to take % out of loop
Feb 5, 2011 at 8:35 comment added Kiril @Saeed, I was running it in release mode through the exe this whole time... in command prompt I get similar results: Plain: 0.0114577 Mod: 0.0017611 Mask: 0.001707
Feb 5, 2011 at 8:33 comment added Saeed Any time you're doing perf tests, you have to build it in release mode, and then run it outside of Visual Studio. Even in release mode, VS does extra things to aid in debugging. Try running from the command line and see what happens.
Feb 5, 2011 at 8:29 comment added Kiril Note that the version you've suggested also captures the incrementation of the indexes (which should always be the same, but it may have some impact). The above results were with a version nearly identical to yours although I avoid the use of the Func delegate, here is a pastie for it: pastie.org/1530568
Feb 5, 2011 at 8:11 comment added Kiril Are you running it in release mode? I'm seeing almost no difference even if I only reset the stopwatch once and I cast the elapsed ticks to doubles: Plain: 0.011272 Mod: 0.001699 Mask: 0.001698
Feb 5, 2011 at 8:05 history edited Saeed CC BY-SA 2.5
Removed the index methods because they duplicate the code in the question and aren't relevant to the answer.
Feb 5, 2011 at 7:47 history edited Saeed CC BY-SA 2.5
Added an additional point about rounding.
Feb 5, 2011 at 7:38 history answered Saeed CC BY-SA 2.5