Measuring Performances of a Classic LINQ Query

The goal of this paragraph is to explain how you can execute a classic LINQ query over intensive processing and measure its performance in milliseconds. Consider the following code:

image

Given a range of predefined numbers (Enumerable.Range), the code looks for odd numbers and collects them into an IEnumerable(Of Integer). To measure performance, we can take advantage of the Stopwatch class that basically starts a counter (Stopwatch.StartNew). Because, as you already know, LINQ queries are effectively executed when you use them, such a query is executed when the code invokes the Count property to show ...

Get Visual Basic 2010 Unleashed now with O’Reilly online learning.

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