Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

Question about Parallel processing...

$
0
0
Hi VBForums. The past few days I have been reading a bit about when to use the Task Parallel Library for CPU bound tasks.

However, the Parallel.For method is actually performing worse than a standard For loop.

For testing, all I am doing is incrementing an integer variable +1 on each iteration.

Dim number as Integer = 0

For i = 0 To Integer.MaxValue - 1
number += 1
Next

This takes 4 seconds for the 21 billion iterations, but when I use Parallel.For, it is taking much longer too complete.

Isn't adding an integer to another integer a CPU bound task?

Thanks!

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>