Program.cs
92 lines
| 2.9 KiB
| text/x-csharp
|
CSharpLexer
/ Implab.Playground / Program.cs
|
|
r229 | using Implab.Formats.Json; | ||
|
|
r233 | using Implab.Parallels; | ||
|
|
r229 | using Implab.Xml; | ||
| using System; | ||||
|
|
r233 | using System.Collections.Concurrent; | ||
|
|
r229 | using System.Collections.Generic; | ||
| using System.IO; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
|
|
r233 | using System.Threading; | ||
|
|
r229 | using System.Threading.Tasks; | ||
| using System.Xml; | ||||
| using System.Xml.Serialization; | ||||
| namespace Implab.Playground { | ||||
| public class Program { | ||||
|
|
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]); | ||||
| } | ||||
|
|
r229 | |||
|
|
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; | ||||
| } | ||||
|
|
r229 | |||
|
|
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]); | ||||
| } | ||||
|
|
r229 | |||
|
|
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; | ||||
| } | ||||
|
|
r234 | |||
|
|
r233 | |||
|
|
r234 | /*static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) { | ||
|
|
r233 | q.EnqueueRange(data, offset, len); | ||
|
|
r229 | } | ||
|
|
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); | ||||
|
|
r234 | }*/ | ||
|
|
r233 | |||
|
|
r229 | static void Main(string[] args) { | ||
|
|
r236 | var t = Environment.TickCount; | ||
| using (var reader = JsonReader.Create("e:\\citylots.json")) { | ||||
| while (reader.Read()) { | ||||
| } | ||||
| } | ||||
| Console.WriteLine($"JsonReader: {Environment.TickCount - t} ms"); | ||||
|
|
r229 | |||
| Console.WriteLine("done"); | ||||
| } | ||||
| } | ||||
| } | ||||
