Commit e10c20e2 authored by Jeremy Meng's avatar Jeremy Meng

Replace usage of SpinWait struct with simple increment operation. ...

Replace usage of SpinWait struct with simple increment operation.  SpinWait.SpinOnce() takes too much time than the original Thread.SpinWait(5).
parent 99ad4d1e
...@@ -35,15 +35,15 @@ static void MassiveBulkOpsAsync(int AsyncOpsQty, bool preserveOrder, bool withCo ...@@ -35,15 +35,15 @@ static void MassiveBulkOpsAsync(int AsyncOpsQty, bool preserveOrder, bool withCo
var conn = muxer.GetDatabase(); var conn = muxer.GetDatabase();
muxer.Wait(conn.PingAsync()); muxer.Wait(conn.PingAsync());
int number = 0;
Action<Task> nonTrivial = delegate Action<Task> nonTrivial = delegate
{ {
#if !DNXCORE50 #if !DNXCORE50
Thread.SpinWait(5); Thread.SpinWait(5);
#else #else
var spinWait = new SpinWait(); for (int i = 0; i < 50; i++)
for (int i = 0; i < 5; i++)
{ {
spinWait.SpinOnce(); number++;
} }
#endif #endif
}; };
......
...@@ -234,15 +234,15 @@ public void MassiveBulkOpsAsync(bool preserveOrder, bool withContinuation) ...@@ -234,15 +234,15 @@ public void MassiveBulkOpsAsync(bool preserveOrder, bool withContinuation)
var conn = muxer.GetDatabase(); var conn = muxer.GetDatabase();
muxer.Wait(conn.PingAsync()); muxer.Wait(conn.PingAsync());
int number = 0;
Action<Task> nonTrivial = delegate Action<Task> nonTrivial = delegate
{ {
#if !DNXCORE50 #if !DNXCORE50
Thread.SpinWait(5); Thread.SpinWait(5);
#else #else
var spinWait = new SpinWait(); for (int i = 0; i < 50; i++)
for (int i = 0; i < 5; i++)
{ {
spinWait.SpinOnce(); number++;
} }
#endif #endif
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment