Mercurial > pub > ImplabNet
comparison MonoPlay/Program.cs @ 150:3258399cba83 v2
JSONWriter improvements
author | cin |
---|---|
date | Sat, 12 Dec 2015 22:12:44 +0300 |
parents | 706fccb85524 |
children | ec91a6dfa5b3 |
comparison
equal
deleted
inserted
replaced
149:eb793fbbe4ea | 150:3258399cba83 |
---|---|
3 using Implab.Parallels; | 3 using Implab.Parallels; |
4 using Implab; | 4 using Implab; |
5 using System.Collections.Generic; | 5 using System.Collections.Generic; |
6 using System.Collections.Concurrent; | 6 using System.Collections.Concurrent; |
7 using System.Threading; | 7 using System.Threading; |
8 using Implab.JSON; | |
9 using System.IO; | |
8 | 10 |
9 namespace MonoPlay { | 11 namespace MonoPlay { |
10 class MainClass { | 12 class MainClass { |
11 | 13 |
12 | 14 |
14 if (args == null) | 16 if (args == null) |
15 throw new ArgumentNullException("args"); | 17 throw new ArgumentNullException("args"); |
16 | 18 |
17 var t1 = Environment.TickCount; | 19 var t1 = Environment.TickCount; |
18 | 20 |
19 for (int i = 0; i < 10000000; i++) { | 21 for(int i =0; i < 1000000; i++) |
20 | 22 using (var tw = new StringWriter()) { |
21 var p = new Promise<int>(); | 23 var jw = new JSONWriter(tw); |
22 p.On(HandleResult); | 24 |
23 p.Resolve(i); | 25 jw.WriteValue("\r\nhere\tvalue\u0002\u0003"); |
26 | |
27 //Console.WriteLine(tw); | |
24 } | 28 } |
29 | |
30 | |
25 | 31 |
26 var t2 = Environment.TickCount; | 32 var t2 = Environment.TickCount; |
27 Console.WriteLine("done: {0} ms, {1:.00} Mb, {2} GC", t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0) ); | 33 Console.WriteLine("done: {0} ms, {1:.00} Mb, {2} GC", t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0) ); |
28 | 34 |
29 } | 35 } |
30 | 36 |
31 static void HandleAction () | 37 static void DoTest() { |
32 { | 38 |
33 | 39 |
40 | |
34 } | 41 } |
35 | 42 |
36 static void HandleResult(int x) { | |
37 | |
38 } | |
39 } | 43 } |
40 } | 44 } |