229
|
1 using Implab.Formats.Json;
|
233
|
2 using Implab.Parallels;
|
229
|
3 using Implab.Xml;
|
|
4 using System;
|
233
|
5 using System.Collections.Concurrent;
|
229
|
6 using System.Collections.Generic;
|
|
7 using System.IO;
|
|
8 using System.Linq;
|
|
9 using System.Text;
|
233
|
10 using System.Threading;
|
229
|
11 using System.Threading.Tasks;
|
|
12 using System.Xml;
|
|
13 using System.Xml.Serialization;
|
|
14
|
|
15 namespace Implab.Playground {
|
|
16 public class Program {
|
|
17
|
233
|
18 static void EnqueueRange<T>(ConcurrentQueue<T> q, T[] data, int offset, int len) {
|
|
19 for (var i = offset; i < offset + len; i++)
|
|
20 q.Enqueue(data[i]);
|
|
21 }
|
|
22
|
|
23 static bool TryDequeueRange<T>(ConcurrentQueue<T> q,T[] buffer,int offset, int len, out int actual) {
|
|
24 actual = 0;
|
|
25 T res;
|
|
26 while(q.TryDequeue(out res)) {
|
|
27 buffer[offset + actual] = res;
|
|
28 actual++;
|
|
29 if (actual == len)
|
|
30 break;
|
|
31 }
|
|
32 return actual != 0;
|
|
33 }
|
|
34
|
|
35 static void EnqueueRange<T>(SimpleAsyncQueue<T> q, T[] data, int offset, int len) {
|
|
36 for (var i = offset; i < offset + len; i++)
|
|
37 q.Enqueue(data[i]);
|
|
38 }
|
229
|
39
|
233
|
40 static bool TryDequeueRange<T>(SimpleAsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
|
|
41 actual = 0;
|
|
42 T res;
|
|
43 while (q.TryDequeue(out res)) {
|
|
44 buffer[offset + actual] = res;
|
|
45 actual++;
|
|
46 if (actual == len)
|
|
47 break;
|
|
48 }
|
|
49 return actual != 0;
|
|
50 }
|
229
|
51
|
233
|
52 static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
|
|
53 for (var i = offset; i < offset + len; i++)
|
|
54 q.Enqueue(data[i]);
|
|
55 }
|
229
|
56
|
233
|
57 static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
|
|
58 actual = 0;
|
|
59 T res;
|
|
60 while (q.TryDequeue(out res)) {
|
|
61 buffer[offset + actual] = res;
|
|
62 actual++;
|
|
63 if (actual == len)
|
|
64 break;
|
|
65 }
|
|
66 return actual != 0;
|
|
67 }
|
234
|
68
|
233
|
69
|
234
|
70 /*static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) {
|
233
|
71 q.EnqueueRange(data, offset, len);
|
229
|
72 }
|
|
73
|
233
|
74 static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) {
|
|
75 return q.TryDequeueRange(buffer, offset, len, out actual);
|
234
|
76 }*/
|
233
|
77
|
|
78
|
229
|
79 static void Main(string[] args) {
|
|
80
|
236
|
81 var t = Environment.TickCount;
|
|
82 using (var reader = JsonReader.Create("e:\\citylots.json")) {
|
|
83 while (reader.Read()) {
|
|
84 }
|
|
85 }
|
|
86
|
|
87 Console.WriteLine($"JsonReader: {Environment.TickCount - t} ms");
|
229
|
88
|
|
89 Console.WriteLine("done");
|
|
90 }
|
|
91 }
|
|
92 }
|