In the example code you'll also find a slightly better (and more precise) version that uses GetTickCount rather then the current time (Now), although if you are looking for really precise timing you would be better off using the specific timing service offered by the QueryPerformanceCounter Windows API.
Notice, though that if you execute the standard version and the one based on anonymous methods you'll get output like the following: Classic
As you can see, the anonymous method version sees a penalty of roughly 8%. The reason is that rather than directly executing the local code, the program has to make a virtual call to the anonymous method implementation. As this difference is consistent, the testing code makes perfect sense anyway. However, if you need to squeeze performance from your code, using anonymous method won't be as fast as directly writing the code, with using a direct function. Using a method pointer would probably be somewhere in between the two in terms of performance.
Was this article helpful?
What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.