public void Benchmark(int pointCount) { SortedPointBuffer <HistorianKey, HistorianValue> points = new SortedPointBuffer <HistorianKey, HistorianValue>(pointCount, true); HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); for (int x = 0; x < pointCount; x++) { key.PointID = (ulong)x; points.TryEnqueue(key, value); } points.IsReadingMode = true; Stopwatch sw = new Stopwatch(); sw.Start(); using (BinaryStream bs = new BinaryStream(true)) { SequentialSortedTreeWriter <HistorianKey, HistorianValue> .Create(bs, 4096, HistorianFileEncodingDefinition.TypeGuid, points); //SequentialSortedTreeWriter<HistorianKey, HistorianValue>.Create(bs, 4096, SortedTree.FixedSizeNode, points); } sw.Stop(); System.Console.WriteLine("Points {0}: {1}MPPS", pointCount, (pointCount / sw.Elapsed.TotalSeconds / 1000000).ToString("0.0")); }
public void Test(int pointCount) { SortedPointBuffer <HistorianKey, HistorianValue> points = new SortedPointBuffer <HistorianKey, HistorianValue>(pointCount, true); Random r = new Random(1); HistorianKey key = new HistorianKey(); HistorianValue value = new HistorianValue(); for (int x = 0; x < pointCount; x++) { key.PointID = (ulong)r.Next(); key.Timestamp = (ulong)r.Next(); value.Value1 = key.PointID; points.TryEnqueue(key, value); } points.IsReadingMode = true; using (BinaryStream bs = new BinaryStream(true)) { //var tree = new SequentialSortedTreeWriter<HistorianKey, HistorianValue>(bs, 256, SortedTree.FixedSizeNode); //SequentialSortedTreeWriter<HistorianKey, HistorianValue>.Create(bs, 512, CreateTsCombinedEncoding.TypeGuid, points); SequentialSortedTreeWriter <HistorianKey, HistorianValue> .Create(bs, 512, EncodingDefinition.FixedSizeCombinedEncoding, points); SortedTree <HistorianKey, HistorianValue> sts = SortedTree <HistorianKey, HistorianValue> .Open(bs); r = new Random(1); for (int x = 0; x < pointCount; x++) { key.PointID = (ulong)r.Next(); key.Timestamp = (ulong)r.Next(); sts.Get(key, value); if (value.Value1 != key.PointID) { throw new Exception(); } } } }