Mercurial > pub > ImplabNet
view Implab.Playground/Program.cs @ 242:cbe10ac0731e v3
Working on promises
author | cin |
---|---|
date | Wed, 24 Jan 2018 03:03:21 +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"); } } }