C# Programming > Miscellaneous

This simple C# project will help you when optimizing your C# applications. The application will take a code-snippet and run it through a loop for a specified number of times. Remember to set the number high enough to notice a change in speed.
For tips on improving C# source code performance visit the Code Optimization Article.
The utility measures the speed of the C#.Net code by using the System.Diagnostics StopWatch class. The StopWatch class comes with two functions that we use: Start() and Stop(). Underneath those functions they are using the API call QueryPerformanceTimer, which is a high-precision timer of better accurancy than using DateTime.Now. Here is the basic C# code:
StopWatch timer = new StopWatch();
timer.Start(); //Some code timer.Stop();
TimeSpan speed = new TimeSpan(timer.ElapsedTicks);
I recommend you work with the utility from inside Visual Studio (or Express Edition). C# applications executed from within the debugging environment run slower which is actually a good thing. In other words it will make it easier to notice speed improvements or fallbacks from tweaking your C# code...
Download Speed Tester C# Source Code