Program.cs
45 lines
| 1.4 KiB
| text/x-csharp
|
CSharpLexer
/ MonoPlay / Program.cs
|
|
r93 | using System; | ||
| using Implab; | ||||
|
|
r151 | using System.Threading.Tasks; | ||
|
|
r183 | using Implab.Formats.JSON; | ||
| using System.IO; | ||||
| using System.Text.Json; | ||||
|
|
r93 | |||
| namespace MonoPlay { | ||||
| class MainClass { | ||||
|
|
r145 | |||
|
|
r93 | public static void Main(string[] args) { | ||
|
|
r94 | if (args == null) | ||
| throw new ArgumentNullException("args"); | ||||
|
|
r183 | int t1, t2; | ||
|
|
r150 | |||
|
|
r183 | 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++; | ||||
| } | ||||
|
|
r93 | |||
|
|
r183 | 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 ); | ||||
| } | ||||
|
|
r136 | |||
|
|
r183 | 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); | ||||
| } | ||||
|
|
r150 | |||
|
|
r183 | 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)); | ||||
| } | ||||
|
|
r145 | } | ||
|
|
r136 | |||
|
|
r93 | } | ||
| } | ||||
