public void CountIO() { Test(1000, false); int pointCount = 10000000; 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; File.Delete(@"C:\Temp\fileTemp.~d2i"); File.Delete(@"C:\Temp\fileTemp.d2i"); Stopwatch sw = new Stopwatch(); sw.Start(); SortedTreeFileSimpleWriter <HistorianKey, HistorianValue> .Create(@"C:\Temp\fileTemp.~d2i", @"C:\Temp\fileTemp.d2i", 4096, null, EncodingDefinition.FixedSizeCombinedEncoding, points); sw.Stop(); System.Console.WriteLine(SimplifiedSubFileStreamIoSession.ReadBlockCount); System.Console.WriteLine(SimplifiedSubFileStreamIoSession.WriteBlockCount); System.Console.WriteLine(sw.Elapsed.TotalSeconds.ToString()); }
public void TestNonSequential(int pointCount, bool verify) { 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; File.Delete(@"C:\Temp\fileTemp.~d2i"); File.Delete(@"C:\Temp\fileTemp.d2i"); SortedTreeFileSimpleWriter <HistorianKey, HistorianValue> .CreateNonSequential(@"C:\Temp\fileTemp.~d2i", @"C:\Temp\fileTemp.d2i", 4096, null, EncodingDefinition.FixedSizeCombinedEncoding, points); if (!verify) { return; } using (SortedTreeFile file = SortedTreeFile.OpenFile(@"C:\Temp\fileTemp.d2i", true)) using (SortedTreeTable <HistorianKey, HistorianValue> table = file.OpenTable <HistorianKey, HistorianValue>()) using (SortedTreeTableReadSnapshot <HistorianKey, HistorianValue> read = table.AcquireReadSnapshot().CreateReadSnapshot()) using (SortedTreeScannerBase <HistorianKey, HistorianValue> scanner = read.GetTreeScanner()) { scanner.SeekToStart(); int cnt = 0; while (scanner.Read(key, value)) { if (key.PointID != (ulong)cnt) { throw new Exception(); } cnt++; } if (cnt != pointCount) { throw new Exception(); } } }