# HG changeset patch
# User cin
# Date 1415430167 -10800
# Node ID b3f5bc613905599a49dd0df54c2c5cf884116b51
# Parent b4c4d65b7def5004045497dfe1592613d6fef908
sync
diff -r b4c4d65b7def -r b3f5bc613905 MonoPlay/MonoPlay.csproj
--- a/MonoPlay/MonoPlay.csproj Fri Nov 07 09:36:12 2014 +0300
+++ b/MonoPlay/MonoPlay.csproj Sat Nov 08 10:02:47 2014 +0300
@@ -27,7 +27,7 @@
bin\Release
prompt
4
- true
+ false
diff -r b4c4d65b7def -r b3f5bc613905 MonoPlay/Program.cs
--- a/MonoPlay/Program.cs Fri Nov 07 09:36:12 2014 +0300
+++ b/MonoPlay/Program.cs Sat Nov 08 10:02:47 2014 +0300
@@ -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 @@
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);
}
}