Using a Stopwatch Timer to Measure Code Execution Time

If you are working on a production application that will ship on the .NET Compact Framework platform, chances are you will be doing performance analysis on the application code. As this chapter is being written, the performance profiling tools on the market for the .NET Compact Framework are few and far between. Despite this lack of performance tools, there are some simple techniques that can be used to profile an application's performance traits.

First, it is important to have a reliable way to measure the execution time of a block of code. The .NET Compact Framework provides the TickCount property on the Environment class in the System namespace. This property can be used to calculate the ...

Get Microsoft® .NET Compact Framework Kick Start now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.