Measuring Performances of a PLINQ Query
To create a parallel query, you 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 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. However, it works as an IEnumerable(Of T)
but enables you to scale data over multicore processors. Now edit Sub Main
so that it invokes the PLinqQuery
method and runs the code again. Figure 41.8 shows what you should see when the application is processing ...
Get Visual Basic 2015 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.