# HG changeset patch # User cin # Date 2014-11-08 07:02:47 # Node ID b3f5bc613905599a49dd0df54c2c5cf884116b51 # Parent b4c4d65b7def5004045497dfe1592613d6fef908 sync diff --git a/MonoPlay/MonoPlay.csproj b/MonoPlay/MonoPlay.csproj --- a/MonoPlay/MonoPlay.csproj +++ b/MonoPlay/MonoPlay.csproj @@ -27,7 +27,7 @@ bin\Release prompt 4 - true + false diff --git a/MonoPlay/Program.cs b/MonoPlay/Program.cs --- a/MonoPlay/Program.cs +++ b/MonoPlay/Program.cs @@ -2,6 +2,8 @@ using Implab.Diagnostics; using Implab.Parallels; using Implab; +using System.Collections.Generic; +using System.Collections.Concurrent; namespace MonoPlay { class MainClass { @@ -9,23 +11,37 @@ namespace MonoPlay { if (args == null) throw new ArgumentNullException("args"); - var listener = new ConsoleTraceListener(true); - listener.Subscribe(); + var q1 = new MTQueue(); + var q2 = new ConcurrentQueue(); + + const int count = 10000000; + + var t1 = Environment.TickCount; - MTComponentContainer.AppContainer.Add(listener); + for (var i = 0; i < count; i++) + q1.Enqueue(i); - TraceLog.StartLogicalOperation("program"); + var t2 = Environment.TickCount; + Console.WriteLine("MTQueue: {0} ms", t2 - t1); + + t1 = Environment.TickCount; - TraceLog.StartLogicalOperation("async"); - AsyncPool.Invoke(() => { - TraceLog.TraceInformation("Hello async"); - TraceLog.StartLogicalOperation("foo"); - return 0; - }) - .EndLogicalOperation() - .Join(); + for (var i = 0; i < count; i++) + q2.Enqueue(i); + + t2 = Environment.TickCount; + Console.WriteLine("LinkedList: {0} ms", t2 - t1); + + q2 = new ConcurrentQueue(); - TraceLog.EndLogicalOperation(); + t1 = Environment.TickCount; + + for (var i = 0; i < count; i++) + lock (q2) + q2.Enqueue(i); + + t2 = Environment.TickCount; + Console.WriteLine("LinkedList+Lock: {0} ms", t2 - t1); } }