##// END OF EJS Templates
minor changes
minor changes

File last commit:

r108:f3bdb7ba59b9 v2
r114:3fbc6eb93eb1 v2
Show More
Program.cs
79 lines | 2.2 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
sync
r103 var q1 = new MTQueue<int>();
cin
renamed Promise.Last -> Promise.On...
r104 var q2 = new Queue<int>();
cin
sync
r103
const int count = 10000000;
cin
sync
r108
cin
sync
r103 var t1 = Environment.TickCount;
cin
improved tracing...
r93
cin
sync
r108 Promise<int>.CreateComposite(
new [] {
AsyncPool.InvokeNewThread(() => {
for (var i = 0; i < count; i++)
q1.Enqueue(i);
}),
AsyncPool.InvokeNewThread(() => {
int temp = 0;
for(int i =0 ; i< count ; i++)
while(!q1.TryDequeue(out temp)){
}
})
}
).Join();
cin
improved tracing...
r93
cin
sync
r103 var t2 = Environment.TickCount;
Console.WriteLine("MTQueue: {0} ms", t2 - t1);
t1 = Environment.TickCount;
cin
improved tracing...
r93
cin
sync
r103 for (var i = 0; i < count; i++)
q2.Enqueue(i);
t2 = Environment.TickCount;
Console.WriteLine("LinkedList: {0} ms", t2 - t1);
cin
renamed Promise.Last -> Promise.On...
r104 q2 = new Queue<int>();
cin
improved tracing...
r93
cin
sync
r103 t1 = Environment.TickCount;
cin
sync
r108 Promise<int>.CreateComposite(
new [] {
AsyncPool.InvokeNewThread(() => {
for (var i = 0; i < count; i++)
lock (q2)
q2.Enqueue(i);
}),
AsyncPool.InvokeNewThread(() => {
for(int i = 0 ; i< count ;)
lock(q2) {
if(q2.Count == 0)
continue;
q2.Dequeue();
i++;
}
})
}
).Join();
cin
sync
r103
t2 = Environment.TickCount;
Console.WriteLine("LinkedList+Lock: {0} ms", t2 - t1);
cin
improved tracing...
r93
}
}
}