Measuring Performances of a PLINQ Query

To create a parallel query, you simply need to invoke the AsParallel extension method for the data source you want to query. Copy the method shown in the previous paragraph and rename it as PLinqQuery; then simply change the first line of the query as follows:

Dim query = From num In range.AsParallel

Different from a LINQ query, AsParallel returns a ParallelQuery(Of T) that is exposed by the System.Linq namespace and that is specific for PLINQ, although it works as an IEnumerable(Of T) but it allows scaling data over multicore processors. Now edit Sub Main so that it invokes the PLinqQuery method and runs the code again. Figure 29.2 shows what you should see when the application is processing data.

Figure ...

Get Visual Basic® 2010 Unleashed 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.