Concurrency Part 4 – .NET with P/Invoke

This is the fourth part of the Concurrency series. For your convenience you can find other parts in the table of contents in Part 1 – Mutex performance in .NET

We have already seen a mutex in C# but last time it happened that Java JNI is faster. Let’s compare it with P/Invoke.

Code

As always, nothing special. Let’s see the results.

Results

    \[ \begin{array}{cc} Number\ of\ processes & Time [ms] \\ 1 & 110\\ 2 & 620\\ 3 & 1011\\ 4 & 1346\\ 5 & 1728\\ 6 & 2072\\ 7 & 2456\\ 8 & 2803\\ 9 & 3254\\ 10 & 3627\\ \end{array} \]

Well, slightly better than in pure C#, however, still worse than JNI. It’s time to go down.