Measuring Execution Time
The System.Environment namespace has a TickCount property, which returns the number of milliseconds relative to an internal system timer. (This value is slightly different from the Ticks value discussed in Chapter 6, “Storing Information in Variables,” because it represents milliseconds rather than nanoseconds and is stored in a variable of type Integer.) However, it is a great tool for measuring execution time, because we are not interested in the actual time value itself, but rather duration.
→ For more on dates and time spans, see Chapter 6, “Storing Information in Variables,” p.139
Listing 26.4 shows how you can subtract tick counts to determine the time it takes to execute a method:
Listing 26.4. PERFORMANCE.ZIP ...
Get Special Edition Using Microsoft® Visual Basic® .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.