예제 #1
0
        private static void RunTest(string testName, Action <Action <string> > test)
        {
            Console.WriteLine("Running {0}", testName);

            if (!Directory.Exists(_storagePath))
            {
                Directory.CreateDirectory(_storagePath);
            }

            TimeMeasure.Start(testName);
            try
            {
                test(message =>
                {
                    TimeMeasure.Stop(testName);
                    WriteInfo($"{TimeMeasure.Result(testName):hh\\:mm\\:ss\\:fff} {message}");
                    TimeMeasure.Start(testName);
                });
            }
            finally
            {
                TimeMeasure.Stop(testName);
                Cleanup();
            }
        }
예제 #2
0
        private static void PrintResults()
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Results");

            foreach (var name in TimeMeasure.MeasureNames.OrderBy(TimeMeasure.Result))
            {
                Console.WriteLine("{0} time is {1:hh\\:mm\\:ss\\:fff}", name, TimeMeasure.Result(name));
            }

            Console.WriteLine();

            foreach (var name in Counter.CounterNames.OrderBy(Counter.Result))
            {
                Console.WriteLine("{0} counter is {1}", name, Counter.Result(name));
            }

            Console.WriteLine();
        }
예제 #3
0
        private void btnStartGeneration_Click(object sender, EventArgs e)
        {
            int start = int.Parse(nudStartKey.Value.ToString(CultureInfo.InvariantCulture));
            int count = int.Parse(nudKeyCount.Value.ToString(CultureInfo.InvariantCulture));

            TimeMeasure.Start();
            try
            {
                for (int i = start; i < start + count; i++)
                {
                    if (_storageClosing)
                    {
                        break;
                    }
                    _storage.Set(i, RandomString(_random.Next(500)));

                    if (i % 1000 == 0)
                    {
                        lblState.Text = $"Inserting value {i}...";
                        Application.DoEvents();
                    }
                }

                if (!_storageClosing)
                {
                    lblState.Text = "Flushing...";
                    Application.DoEvents();
                    _storage.Flush();
                }
            }
            finally
            {
                TimeMeasure.Stop();
            }

            lblState.Text = $"Done! Elapsed time: {TimeMeasure.Result()}";
            TimeMeasure.Reset();
        }