93
|
1 using System;
|
|
2 using Implab;
|
151
|
3 using System.Threading.Tasks;
|
183
|
4 using Implab.Formats.JSON;
|
|
5 using System.IO;
|
|
6 using System.Text.Json;
|
93
|
7
|
|
8 namespace MonoPlay {
|
|
9 class MainClass {
|
145
|
10
|
|
11
|
93
|
12 public static void Main(string[] args) {
|
94
|
13 if (args == null)
|
|
14 throw new ArgumentNullException("args");
|
183
|
15 int t1, t2;
|
150
|
16
|
183
|
17 for (int i = 0; i < 2; i++) {
|
|
18 t1 = Environment.TickCount;
|
|
19 int elements =0;
|
|
20 using (var reader = new JSONParser(File.OpenText("/home/sergey/temp/citylots.json"))) {
|
|
21 while (reader.Read())
|
|
22 elements++;
|
|
23 }
|
93
|
24
|
183
|
25 t2 = Environment.TickCount;
|
|
26 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 );
|
|
27 }
|
136
|
28
|
183
|
29 Console.WriteLine("Syste.Text.Json");
|
|
30 var paraser = new JsonParser();
|
|
31 for (int i = 0; i < 2; i++) {
|
|
32 t1 = Environment.TickCount;
|
|
33 using (var reader = File.OpenText("/home/sergey/temp/citylots.json")) {
|
|
34 paraser.Parse(reader);
|
|
35 }
|
150
|
36
|
183
|
37 t2 = Environment.TickCount;
|
|
38 Console.WriteLine("attempt {0} done: {1} ms, {2:.00} Mb, {3} GC, ",i+1, t2 - t1, GC.GetTotalMemory(false) / (1024*1024), GC.CollectionCount(0));
|
|
39 }
|
|
40
|
|
41
|
145
|
42 }
|
136
|
43
|
93
|
44 }
|
|
45 }
|