annotate MonoPlay/Program.cs @ 125:f803565868a4 v2

improved performance of promises
author cin
date Thu, 15 Jan 2015 12:09:20 +0300
parents a336cb13c6a9
children e9e7940c7d98
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 const int count = 10000000;
cin
parents: 94
diff changeset
15
cin
parents: 94
diff changeset
16 var t1 = Environment.TickCount;
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
17
125
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
18 for (int i = 0; i < count; i++) {
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
19 var p = new Promise<int>();
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
20
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
21 p.On(x => {}).On(x => {});
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
22
125
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
23 p.Resolve(i);
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
24
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
25 }
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
26
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
27
121
62d2f1e98c4e working version of AsyncQueue and batch operations
cin
parents: 120
diff changeset
28
103
cin
parents: 94
diff changeset
29 var t2 = Environment.TickCount;
125
f803565868a4 improved performance of promises
cin
parents: 124
diff changeset
30 Console.WriteLine("done: {0} ms, {1:.00} Mb, {2} GC", t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0) );
93
dc4942d09e74 improved tracing
cin
parents:
diff changeset
31
dc4942d09e74 improved tracing
cin
parents:
diff changeset
32 }
dc4942d09e74 improved tracing
cin
parents:
diff changeset
33 }
dc4942d09e74 improved tracing
cin
parents:
diff changeset
34 }