diff MonoPlay/Program.cs @ 121:62d2f1e98c4e v2

working version of AsyncQueue and batch operations tests
author cin
date Mon, 12 Jan 2015 18:19:41 +0300
parents f1b897999260
children 0c8685c8b56b
line wrap: on
line diff
--- a/MonoPlay/Program.cs	Mon Jan 12 05:19:52 2015 +0300
+++ b/MonoPlay/Program.cs	Mon Jan 12 18:19:41 2015 +0300
@@ -16,36 +16,46 @@
 
             const int count = 10000000;
 
-
+            int res1 = 0, res2 = 0;
             var t1 = Environment.TickCount;
 
-            AsyncPool.ThreadRun(
+            AsyncPool.RunThread(
                 () => {
                     for (var i = 0; i < count; i++)
-                        q1.Enqueue(i);
+                        q1.Enqueue(1);
+                    Console.WriteLine("done writer #1: {0} ms", Environment.TickCount - t1);
                 },
                 () => {
                     for (var i = 0; i < count; i++)
-                        q1.Enqueue(i);
+                        q1.Enqueue(2);
+                    Console.WriteLine("done writer #2: {0} ms", Environment.TickCount - t1);
                 },
                 () => {
                     int temp = 0;
                     int i = 0;
                     while (i < count)
-                        if (q1.TryDequeue(out temp))
+                        if (q1.TryDequeue(out temp)) {
                             i++;
+                            res1 += temp;
+                        }
+                    Console.WriteLine("done reader #1: {0} ms", Environment.TickCount - t1);
                 },
                 () => {
                     int temp = 0;
                     int i = 0;
                     while (i < count)
-                        if (q1.TryDequeue(out temp))
+                        if (q1.TryDequeue(out temp)) {
                             i++;
+                            res2 += temp;
+                        }
+                    Console.WriteLine("done reader #2: {0} ms", Environment.TickCount - t1);
                 }
             )
                 .Combine()
                 .Join();
 
+            Console.WriteLine("done: {0} ms, summ#1: {1}, summ#2: {2}, total: {3}", Environment.TickCount - t1, res1, res2, res1 + res2);
+
             var t2 = Environment.TickCount;
             Console.WriteLine("MTQueue: {0} ms", t2 - t1);
 
@@ -65,7 +75,7 @@
             t1 = Environment.TickCount;
 
          
-            AsyncPool.ThreadRun(
+            AsyncPool.RunThread(
                 () => {
                     for (var i = 0; i < count; i++)
                         lock (q2)