##// END OF EJS Templates
minor fixes and improvements of AsyncQueue, additional tests
minor fixes and improvements of AsyncQueue, additional tests

File last commit:

r122:0c8685c8b56b v2
r122:0c8685c8b56b v2
Show More
Program.cs
120 lines | 3.6 KiB | text/x-csharp | CSharpLexer
cin
improved tracing...
r93 using System;
using Implab.Diagnostics;
using Implab.Parallels;
using Implab;
cin
sync
r103 using System.Collections.Generic;
using System.Collections.Concurrent;
cin
improved tracing...
r93
namespace MonoPlay {
class MainClass {
public static void Main(string[] args) {
cin
minor fixes
r94 if (args == null)
throw new ArgumentNullException("args");
cin
Promises rewritten, added improved version of AsyncQueue
r119 var q1 = new AsyncQueue<int>();
cin
renamed Promise.Last -> Promise.On...
r104 var q2 = new Queue<int>();
cin
sync
r103
const int count = 10000000;
cin
working version of AsyncQueue and batch operations...
r121 int res1 = 0, res2 = 0;
cin
sync
r103 var t1 = Environment.TickCount;
cin
improved tracing...
r93
cin
working version of AsyncQueue and batch operations...
r121 AsyncPool.RunThread(
cin
improved asyncpool usability...
r120 () => {
cin
Promises rewritten, added improved version of AsyncQueue
r119 for (var i = 0; i < count; i++)
cin
working version of AsyncQueue and batch operations...
r121 q1.Enqueue(1);
Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
cin
improved asyncpool usability...
r120 },
() => {
cin
Promises rewritten, added improved version of AsyncQueue
r119 for (var i = 0; i < count; i++)
cin
working version of AsyncQueue and batch operations...
r121 q1.Enqueue(2);
Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
cin
improved asyncpool usability...
r120 },
() => {
cin
Promises rewritten, added improved version of AsyncQueue
r119 int temp = 0;
int i = 0;
while (i < count)
cin
working version of AsyncQueue and batch operations...
r121 if (q1.TryDequeue(out temp)) {
cin
Promises rewritten, added improved version of AsyncQueue
r119 i++;
cin
working version of AsyncQueue and batch operations...
r121 res1 += temp;
}
Console.WriteLine("done reader #1: {0} ms", Environment.TickCount - t1);
cin
improved asyncpool usability...
r120 },
() => {
cin
Promises rewritten, added improved version of AsyncQueue
r119 int temp = 0;
int i = 0;
while (i < count)
cin
working version of AsyncQueue and batch operations...
r121 if (q1.TryDequeue(out temp)) {
cin
Promises rewritten, added improved version of AsyncQueue
r119 i++;
cin
working version of AsyncQueue and batch operations...
r121 res2 += temp;
}
Console.WriteLine("done reader #2: {0} ms", Environment.TickCount - t1);
cin
improved asyncpool usability...
r120 }
)
cin
Promises rewritten, added improved version of AsyncQueue
r119 .Combine()
.Join();
cin
improved tracing...
r93
cin
minor fixes and improvements of AsyncQueue, additional tests
r122 Console.WriteLine("done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}, count: {4}", Environment.TickCount - t1, res1, res2, res1 + res2, count*2);
cin
working version of AsyncQueue and batch operations...
r121
cin
sync
r103 var t2 = Environment.TickCount;
Console.WriteLine("MTQueue: {0} ms", t2 - t1);
t1 = Environment.TickCount;
cin
improved tracing...
r93
cin
Promises rewritten, added improved version of AsyncQueue
r119 for (var i = 0; i < count * 2; i++)
cin
sync
r103 q2.Enqueue(i);
cin
Promises rewritten, added improved version of AsyncQueue
r119 for (var i = 0; i < count * 2; i++)
q2.Dequeue();
cin
sync
r103 t2 = Environment.TickCount;
cin
Promises rewritten, added improved version of AsyncQueue
r119 Console.WriteLine("Queue: {0} ms", t2 - t1);
cin
sync
r103
cin
renamed Promise.Last -> Promise.On...
r104 q2 = new Queue<int>();
cin
improved tracing...
r93
cin
sync
r103 t1 = Environment.TickCount;
cin
Promises rewritten, added improved version of AsyncQueue
r119
cin
working version of AsyncQueue and batch operations...
r121 AsyncPool.RunThread(
cin
improved asyncpool usability...
r120 () => {
cin
Promises rewritten, added improved version of AsyncQueue
r119 for (var i = 0; i < count; i++)
lock (q2)
q2.Enqueue(i);
cin
improved asyncpool usability...
r120 },
() => {
cin
Promises rewritten, added improved version of AsyncQueue
r119 for (var i = 0; i < count; i++)
lock (q2)
q2.Enqueue(i);
cin
improved asyncpool usability...
r120 },
() => {
cin
Promises rewritten, added improved version of AsyncQueue
r119 for (int i = 0; i < count ;)
lock (q2) {
if (q2.Count == 0)
continue;
q2.Dequeue();
i++;
}
cin
sync
r108
cin
improved asyncpool usability...
r120 },
() => {
cin
Promises rewritten, added improved version of AsyncQueue
r119 for (int i = 0; i < count ;)
lock (q2) {
if (q2.Count == 0)
continue;
q2.Dequeue();
i++;
}
cin
improved asyncpool usability...
r120 }
)
cin
Promises rewritten, added improved version of AsyncQueue
r119 .Combine()
.Join();
cin
sync
r108
cin
sync
r103
t2 = Environment.TickCount;
cin
Promises rewritten, added improved version of AsyncQueue
r119 Console.WriteLine("Queue+Lock: {0} ms", t2 - t1);
cin
improved tracing...
r93
}
}
}