93
|
1 using System;
|
|
2 using Implab.Diagnostics;
|
|
3 using Implab.Parallels;
|
|
4 using Implab;
|
103
|
5 using System.Collections.Generic;
|
|
6 using System.Collections.Concurrent;
|
136
|
7 using System.Threading;
|
150
|
8 using Implab.JSON;
|
|
9 using System.IO;
|
151
|
10 using System.Threading.Tasks;
|
93
|
11
|
|
12 namespace MonoPlay {
|
|
13 class MainClass {
|
145
|
14
|
|
15
|
93
|
16 public static void Main(string[] args) {
|
94
|
17 if (args == null)
|
|
18 throw new ArgumentNullException("args");
|
|
19
|
103
|
20 var t1 = Environment.TickCount;
|
93
|
21
|
151
|
22 DoWork().GetAwaiter().GetResult();
|
150
|
23
|
103
|
24 var t2 = Environment.TickCount;
|
125
|
25 Console.WriteLine("done: {0} ms, {1:.00} Mb, {2} GC", t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0) );
|
93
|
26
|
|
27 }
|
136
|
28
|
151
|
29 static IPromise<int> DoItem(int x) {
|
|
30 return Promise<int>.FromResult(x + 1);
|
|
31 }
|
150
|
32
|
151
|
33 static async Task<int> DoWork() {
|
|
34 var c = 0;
|
|
35 for (int i = 0; i < 10000000; i++)
|
|
36 c = await DoItem(c);
|
|
37 return c;
|
145
|
38 }
|
136
|
39
|
93
|
40 }
|
|
41 }
|