Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 646 Bytes

File metadata and controls

23 lines (19 loc) · 646 Bytes

ReaderWriterLockSlimPerf

Quick spike to test multi-threaded locking perf in response to this article that someone sent me.

Spawns 1000 tasks that aquire a lock, sleep 10ms, and then release the lock.

This only tests the read lock of the ReaderWriterLockSlim.

Perf Chart

Note: I am aware that the lock keyword compiles to basically the following.

bool lockTaken = false;
try
{
  Monitor.Enter(obj, ref lockTaken);
  action();
}
finally
{
  if (lockTaken)
    Monitor.Exit(obj);
}