Program.cs
92 lines
| 2.9 KiB
| text/x-csharp
|
CSharpLexer
/ Implab.Playground / Program.cs
cin
|
r229 | using Implab.Formats.Json; | ||
cin
|
r233 | using Implab.Parallels; | ||
cin
|
r229 | using Implab.Xml; | ||
using System; | ||||
cin
|
r233 | using System.Collections.Concurrent; | ||
cin
|
r229 | using System.Collections.Generic; | ||
using System.IO; | ||||
using System.Linq; | ||||
using System.Text; | ||||
cin
|
r233 | using System.Threading; | ||
cin
|
r229 | using System.Threading.Tasks; | ||
using System.Xml; | ||||
using System.Xml.Serialization; | ||||
namespace Implab.Playground { | ||||
public class Program { | ||||
cin
|
r233 | static void EnqueueRange<T>(ConcurrentQueue<T> q, T[] data, int offset, int len) { | ||
for (var i = offset; i < offset + len; i++) | ||||
q.Enqueue(data[i]); | ||||
} | ||||
static bool TryDequeueRange<T>(ConcurrentQueue<T> q,T[] buffer,int offset, int len, out int actual) { | ||||
actual = 0; | ||||
T res; | ||||
while(q.TryDequeue(out res)) { | ||||
buffer[offset + actual] = res; | ||||
actual++; | ||||
if (actual == len) | ||||
break; | ||||
} | ||||
return actual != 0; | ||||
} | ||||
static void EnqueueRange<T>(SimpleAsyncQueue<T> q, T[] data, int offset, int len) { | ||||
for (var i = offset; i < offset + len; i++) | ||||
q.Enqueue(data[i]); | ||||
} | ||||
cin
|
r229 | |||
cin
|
r233 | static bool TryDequeueRange<T>(SimpleAsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) { | ||
actual = 0; | ||||
T res; | ||||
while (q.TryDequeue(out res)) { | ||||
buffer[offset + actual] = res; | ||||
actual++; | ||||
if (actual == len) | ||||
break; | ||||
} | ||||
return actual != 0; | ||||
} | ||||
cin
|
r229 | |||
cin
|
r233 | static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) { | ||
for (var i = offset; i < offset + len; i++) | ||||
q.Enqueue(data[i]); | ||||
} | ||||
cin
|
r229 | |||
cin
|
r233 | static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) { | ||
actual = 0; | ||||
T res; | ||||
while (q.TryDequeue(out res)) { | ||||
buffer[offset + actual] = res; | ||||
actual++; | ||||
if (actual == len) | ||||
break; | ||||
} | ||||
return actual != 0; | ||||
} | ||||
cin
|
r234 | |||
cin
|
r233 | |||
cin
|
r234 | /*static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) { | ||
cin
|
r233 | q.EnqueueRange(data, offset, len); | ||
cin
|
r229 | } | ||
cin
|
r233 | static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) { | ||
return q.TryDequeueRange(buffer, offset, len, out actual); | ||||
cin
|
r234 | }*/ | ||
cin
|
r233 | |||
cin
|
r229 | static void Main(string[] args) { | ||
cin
|
r236 | var t = Environment.TickCount; | ||
using (var reader = JsonReader.Create("e:\\citylots.json")) { | ||||
while (reader.Read()) { | ||||
} | ||||
} | ||||
Console.WriteLine($"JsonReader: {Environment.TickCount - t} ms"); | ||||
cin
|
r229 | |||
Console.WriteLine("done"); | ||||
} | ||||
} | ||||
} | ||||