annotate MonoPlay/Program.cs @ 104:5f10d54b45df v2

renamed Promise.Last -> Promise.On Promise.On doesn't changes Promise.IsExclusive property
author cin
date Sun, 09 Nov 2014 23:03:45 +0300
parents b3f5bc613905
children f3bdb7ba59b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
1 using System;
dc4942d09e74 improved tracing
cin
parents:
diff changeset
2 using Implab.Diagnostics;
dc4942d09e74 improved tracing
cin
parents:
diff changeset
3 using Implab.Parallels;
dc4942d09e74 improved tracing
cin
parents:
diff changeset
4 using Implab;
103
cin
parents: 94
diff changeset
5 using System.Collections.Generic;
cin
parents: 94
diff changeset
6 using System.Collections.Concurrent;
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
7
dc4942d09e74 improved tracing
cin
parents:
diff changeset
8 namespace MonoPlay {
dc4942d09e74 improved tracing
cin
parents:
diff changeset
9 class MainClass {
dc4942d09e74 improved tracing
cin
parents:
diff changeset
10 public static void Main(string[] args) {
94
a43745f81f10 minor fixes
cin
parents: 93
diff changeset
11 if (args == null)
a43745f81f10 minor fixes
cin
parents: 93
diff changeset
12 throw new ArgumentNullException("args");
a43745f81f10 minor fixes
cin
parents: 93
diff changeset
13
103
cin
parents: 94
diff changeset
14 var q1 = new MTQueue<int>();
104
5f10d54b45df renamed Promise.Last -> Promise.On
cin
parents: 103
diff changeset
15 var q2 = new Queue<int>();
103
cin
parents: 94
diff changeset
16
cin
parents: 94
diff changeset
17 const int count = 10000000;
cin
parents: 94
diff changeset
18
cin
parents: 94
diff changeset
19 var t1 = Environment.TickCount;
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
20
103
cin
parents: 94
diff changeset
21 for (var i = 0; i < count; i++)
cin
parents: 94
diff changeset
22 q1.Enqueue(i);
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
23
103
cin
parents: 94
diff changeset
24 var t2 = Environment.TickCount;
cin
parents: 94
diff changeset
25 Console.WriteLine("MTQueue: {0} ms", t2 - t1);
cin
parents: 94
diff changeset
26
cin
parents: 94
diff changeset
27 t1 = Environment.TickCount;
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
28
103
cin
parents: 94
diff changeset
29 for (var i = 0; i < count; i++)
cin
parents: 94
diff changeset
30 q2.Enqueue(i);
cin
parents: 94
diff changeset
31
cin
parents: 94
diff changeset
32 t2 = Environment.TickCount;
cin
parents: 94
diff changeset
33 Console.WriteLine("LinkedList: {0} ms", t2 - t1);
cin
parents: 94
diff changeset
34
104
5f10d54b45df renamed Promise.Last -> Promise.On
cin
parents: 103
diff changeset
35 q2 = new Queue<int>();
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
36
103
cin
parents: 94
diff changeset
37 t1 = Environment.TickCount;
cin
parents: 94
diff changeset
38
cin
parents: 94
diff changeset
39 for (var i = 0; i < count; i++)
cin
parents: 94
diff changeset
40 lock (q2)
cin
parents: 94
diff changeset
41 q2.Enqueue(i);
cin
parents: 94
diff changeset
42
cin
parents: 94
diff changeset
43 t2 = Environment.TickCount;
cin
parents: 94
diff changeset
44 Console.WriteLine("LinkedList+Lock: {0} ms", t2 - t1);
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
45
dc4942d09e74 improved tracing
cin
parents:
diff changeset
46 }
dc4942d09e74 improved tracing
cin
parents:
diff changeset
47 }
dc4942d09e74 improved tracing
cin
parents:
diff changeset
48 }