KChaloux
KChaloux

Reputation: 4038

Can parallel calls slow down a profiler?

I was tasked to find out what's making part of an application I was assigned to so slow. I decided to give the trial of Redgate's Ants Profiler a go. When running it, the majority of hot spots were contained with loops that the original developer wrote as Parallel.For() loops.

Just to see what effect it would have, I replaced them with standard for-loops, and the profiler sped up by several seconds. However, testing without a profiler, using a simple DateTime.Now difference between the start and end of one such loop, shows that the Parallel.For() loop is more than twice as fast.

Is it possible that running the code through the profiler creates an artificial bottleneck when trying to use the Parallel class?

Upvotes: 0

Views: 93

Answers (1)

Daniel
Daniel

Reputation: 31579

The problem is that when doing parallel things, the profiler samples all threads which makes the normal profiler performance drop be bigger with more threads.

Upvotes: 1

Related Questions