Mercurial > pub > ImplabNet
diff MonoPlay/Program.cs @ 183:4f82e0f161c3 ref20160224
fixed DFA optimization, JSON is fully functional
author | cin |
---|---|
date | Fri, 25 Mar 2016 02:49:02 +0300 |
parents | 97fbbf816844 |
children | d45bdf510514 |
line wrap: on
line diff
--- a/MonoPlay/Program.cs Thu Mar 24 18:52:10 2016 +0300 +++ b/MonoPlay/Program.cs Fri Mar 25 02:49:02 2016 +0300 @@ -1,6 +1,9 @@ using System; using Implab; using System.Threading.Tasks; +using Implab.Formats.JSON; +using System.IO; +using System.Text.Json; namespace MonoPlay { class MainClass { @@ -9,28 +12,33 @@ public static void Main(string[] args) { if (args == null) throw new ArgumentNullException("args"); - - var t1 = Environment.TickCount; - - DoWork().GetAwaiter().GetResult(); + int t1, t2; - var t2 = Environment.TickCount; - Console.WriteLine("done: {0} ms, {1:.00} Mb, {2} GC", t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0) ); + for (int i = 0; i < 2; i++) { + t1 = Environment.TickCount; + int elements =0; + using (var reader = new JSONParser(File.OpenText("/home/sergey/temp/citylots.json"))) { + while (reader.Read()) + elements++; + } - } + t2 = Environment.TickCount; + Console.WriteLine("attempt {0} done: {1} ms, {2:.00} Mb, {3} GC, Elements: {4}",i+1, t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0), elements ); + } - static IPromise<int> DoItem(int x) { - //return Promise<int>.FromResult(x + 1); - var p = new Promise<int>(); - p.Resolve(x+1); - return p; - } + Console.WriteLine("Syste.Text.Json"); + var paraser = new JsonParser(); + for (int i = 0; i < 2; i++) { + t1 = Environment.TickCount; + using (var reader = File.OpenText("/home/sergey/temp/citylots.json")) { + paraser.Parse(reader); + } - static async Task<int> DoWork() { - var c = 0; - for (int i = 0; i < 10000000; i++) - c = await DoItem(c); - return c; + t2 = Environment.TickCount; + Console.WriteLine("attempt {0} done: {1} ms, {2:.00} Mb, {3} GC, ",i+1, t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0)); + } + + } }