Mercurial > pub > ImplabNet
view Implab.Playground/Program.cs @ 253:34df34841225 v3 v3.0.1-beta
Implab.Diagnostics drafts
author | cin |
---|---|
date | Mon, 12 Feb 2018 17:03:37 +0300 |
parents | 302ca905c19e |
children | b00441e04738 |
line wrap: on
line source
using Implab.Formats.Json; using Implab.Parallels; using Implab.Xml; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; namespace Implab.Playground { public class Program { 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]); } 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; } 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]); } 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; } /*static void EnqueueRange<T>(AsyncQueue<T> q, T[] data, int offset, int len) { q.EnqueueRange(data, offset, len); } static bool TryDequeueRange<T>(AsyncQueue<T> q, T[] buffer, int offset, int len, out int actual) { return q.TryDequeueRange(buffer, offset, len, out actual); }*/ static void Main(string[] args) { var t = Environment.TickCount; using (var reader = JsonReader.Create("e:\\citylots.json")) { while (reader.Read()) { } } Console.WriteLine($"JsonReader: {Environment.TickCount - t} ms"); Console.WriteLine("done"); } } }