changeset 103:b3f5bc613905 v2

sync
author cin
date Sat, 08 Nov 2014 10:02:47 +0300
parents b4c4d65b7def
children 5f10d54b45df
files MonoPlay/MonoPlay.csproj MonoPlay/Program.cs
diffstat 2 files changed, 30 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
     <OutputPath>bin\Release</OutputPath>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
-    <Externalconsole>true</Externalconsole>
+    <ConsolePause>false</ConsolePause>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
--- 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<TraceEvent>();
+            var q1 = new MTQueue<int>();
+            var q2 = new ConcurrentQueue<int>();
+
+            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<int>();
 
-            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);
 
         }
     }