public static JsonObjectCollection ConvertStatisticToJson(SpeedStatistics statistic, string statisticName)
        {
            JsonObjectCollection jsonTest = new JsonObjectCollection(statisticName);
            JsonArrayCollection jsonRecords = new JsonArrayCollection("Records");
            JsonArrayCollection jsonTime = new JsonArrayCollection("Time");
            JsonArrayCollection jsonAverageSpeed = new JsonArrayCollection("AverageSpeed");
            JsonArrayCollection jsonMomentSpeed = new JsonArrayCollection("MomentSpeed");

            for (int i = 0; i < BenchmarkTest.INTERVAL_COUNT; i++)
            {
                // Number of records & timespan.
                var rec = statistic.GetRecordAt(i);
                jsonRecords.Add(new JsonNumericValue(rec.Key));
                jsonTime.Add(new JsonNumericValue(rec.Value.TotalMilliseconds));

                // Average speed.
                var averageSpeed = statistic.GetAverageSpeedAt(i);
                jsonAverageSpeed.Add(new JsonNumericValue(averageSpeed));

                // Moment write speed.
                var momentSpeed = statistic.GetMomentSpeedAt(i);
                jsonMomentSpeed.Add(new JsonNumericValue(momentSpeed));
            }

            jsonTest.Add(jsonRecords);
            jsonTest.Add(jsonTime);
            jsonTest.Add(jsonAverageSpeed);
            jsonTest.Add(jsonMomentSpeed);

            return jsonTest;
        }
        public BenchmarkTest(Database database, int flowCount, long recordCount, float randomness, CancellationTokenSource cancellation)
        {
            Database = database;

            FlowCount = flowCount;
            RecordCount = recordCount;
            Randomness = randomness;
            KeysType = Randomness == 0f ? KeysType.Sequential : KeysType.Random;

            // Statistics.
            int length = Enum.GetValues(typeof(TestMethod)).Length - 1;

            SpeedStatistics = new SpeedStatistics[length];
            MemoryStatistics = new MemoryStatistics[length];

            int step = (int)((recordCount) / INTERVAL_COUNT);

            for (int i = 0; i < length; i++)
            {
                SpeedStatistics[i] = new SpeedStatistics(INTERVAL_COUNT);
                SpeedStatistics[i].Step = step;

                MemoryStatistics[i] = new MemoryStatistics(INTERVAL_COUNT);
                MemoryStatistics[i].Step = step;
            }

            Cancellation = cancellation;
        }