Beispiel #1
0
        private void Report(BenchmarkSession benchmark, TestMethod method)
        {
            try
            {
                // TODO: Fix this.
                //Action<string, object, Color> updateChart = null;

                //StepFrame ActiveStepFrame = MainLayout.GetCurrentFrame();
                //string databaseName = benchmark.Database.Name;
                //Color databaseColor = benchmark.Database.Color;

                //// Speed chart.
                //updateChart = ActiveStepFrame.AddAverageSpeedToBar;
                //Report(databaseName, databaseColor, updateChart, benchmark.GetAverageSpeed(method));

                //// Size chart.
                //updateChart = ActiveStepFrame.AddSizeToBar;
                //Report(databaseName, databaseColor, updateChart, benchmark.DatabaseSize / (1024.0 * 1024.0));

                //// Time chart.
                //updateChart = ActiveStepFrame.AddTimeToBar;
                //Report(databaseName, databaseColor, updateChart, new DateTime(benchmark.GetElapsedTime(method).Ticks));

                //// Memory chart.
                //updateChart = ActiveStepFrame.AddMemoryUsageToBar;
                //Report(databaseName, databaseColor, updateChart, benchmark.GetPeakWorkingSet(method) / (1024.0 * 1024.0));
            }
            catch (Exception exc)
            {
                Logger.Error("Report results failed...", exc);
            }
        }
        private static void Report(BenchmarkSession benchmark, TestMethod method)
        {
            try
            {
                string databaseName = benchmark.Database.Name;

                Console.WriteLine();

                var speed          = benchmark.GetAverageSpeed(method);
                var size           = (benchmark.DatabaseSize / (1024.0 * 1024.0));
                var elapsedTime    = new TimeSpan(benchmark.GetElapsedTime(method).Ticks);
                var peakWorkingSet = (benchmark.GetPeakWorkingSet(method) / (1024.0 * 1024.0));

                Logger.Info(String.Format("------------------{0} {1}------------------", databaseName, method.ToString()));
                Logger.Info(String.Format("Average speed: {0:#,#} rec/sec", speed));
                Logger.Info(String.Format("Size: {0:f1} MB", size));
                Logger.Info(String.Format("Elapsed time: {0}", elapsedTime));
                Logger.Info(String.Format("Peak memory usage: {0:f0} MB", peakWorkingSet));
                Logger.Info("---------------------------------------");

                Console.WriteLine();
            }
            catch (Exception exc)
            {
                Logger.Error("Report results failed...", exc);
            }
        }
        public static void Start(TestConfiguration configuration)
        {
            History.Clear();
            Cancellation = new CancellationTokenSource();

            foreach (var database in configuration.Databases)
            {
                var session = new BenchmarkSession(database, configuration.FlowCount, configuration.RecordCount, configuration.Randomness, Cancellation);
                History.Add(session);

                var directory = Path.Combine(configuration.DataDirectory, database.Name);

                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
                else
                {
                    Directory.Delete(directory, true);
                    Directory.CreateDirectory(directory);
                }

                database.DataDirectory = directory;
            }

            // Start the benchmark.
            MainTask = Task.Factory.StartNew(DoBenchmark, Cancellation.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
        }
        private static void DoBenchmark()
        {
            BenchmarkSuite testSuite = new BenchmarkSuite();

            testSuite.OnTestMethodCompleted += Report;

            try
            {
                foreach (var session in History)
                {
                    if (Cancellation.IsCancellationRequested)
                    {
                        break;
                    }

                    CurrentSession = session;

                    CurrentStatus = String.Format("{0} Init...", session.Database.Name);
                    testSuite.ExecuteInit(session);

                    CurrentStatus = String.Format("{0} Write...", session.Database.Name);
                    CurrentMethod = TestMethod.Write;
                    testSuite.ExecuteWrite(session);

                    CurrentStatus = String.Format("{0} Read...", session.Database.Name);
                    CurrentMethod = TestMethod.Read;
                    testSuite.ExecuteRead(session);

                    CurrentStatus = String.Format("{0} Secondary Read...", session.Database.Name);
                    CurrentMethod = TestMethod.SecondaryRead;
                    testSuite.ExecuteSecondaryRead(session);

                    testSuite.ExecuteFinish(session);
                }
            }
            finally
            {
                Console.Title = "Tests finished.";

                if (Cancellation.IsCancellationRequested)
                {
                    History.Clear();
                }
            }
        }
        private void Report(BenchmarkSession benchmark, TestMethod method)
        {
            try
            {
                // TODO: Fix this.
                //Action<string, object, Color> updateChart = null;

                //StepFrame ActiveStepFrame = MainLayout.GetCurrentFrame();
                //string databaseName = benchmark.Database.Name;
                //Color databaseColor = benchmark.Database.Color;

                //// Speed chart.
                //updateChart = ActiveStepFrame.AddAverageSpeedToBar;
                //Report(databaseName, databaseColor, updateChart, benchmark.GetAverageSpeed(method));

                //// Size chart.
                //updateChart = ActiveStepFrame.AddSizeToBar;
                //Report(databaseName, databaseColor, updateChart, benchmark.DatabaseSize / (1024.0 * 1024.0));

                //// Time chart.
                //updateChart = ActiveStepFrame.AddTimeToBar;
                //Report(databaseName, databaseColor, updateChart, new DateTime(benchmark.GetElapsedTime(method).Ticks));

                //// Memory chart.
                //updateChart = ActiveStepFrame.AddMemoryUsageToBar;
                //Report(databaseName, databaseColor, updateChart, benchmark.GetPeakWorkingSet(method) / (1024.0 * 1024.0));
            }
            catch (Exception exc)
            {
                Logger.Error("Report results failed...", exc);
            }
        }
 private void OnException(Exception exception, BenchmarkSession test)
 {
     TestFailed = true;
 }
        private void DoBenchmark()
        {
            CurrentTest = new BenchmarkSuite();
            CurrentTest.ExecuteTests(TableCount, RecordCount, Randomness, Cancellation, Test);

            // TODO: Fix this.
            //testSuite.OnTestMethodCompleted += Report;
            //testSuite.OnException += OnException;

            try
            {
                foreach (var benchmark in History)
                {
                    if (Cancellation.IsCancellationRequested)
                        break;

                    //Current = benchmark;
                    //testSuite.ExecuteInit(benchmark);

                    //// Write.
                    //MainLayout.SetCurrentMethod(TestMethod.Write);
                    //CurrentStatus = TestMethod.Write.ToString();

                    //testSuite.ExecuteWrite(benchmark);

                    //// Read.
                    //MainLayout.SetCurrentMethod(TestMethod.Read);
                    //CurrentStatus = TestMethod.Read.ToString();

                    //testSuite.ExecuteRead(benchmark);

                    //// Secondary Read.
                    //MainLayout.SetCurrentMethod(TestMethod.SecondaryRead);
                    //CurrentStatus = TestMethod.SecondaryRead.ToString();

                    //testSuite.ExecuteSecondaryRead(benchmark);

                    //// Finish.
                    //CurrentStatus = TestMethod.None.ToString();
                    //testSuite.ExecuteFinish(benchmark);
                }
            }
            finally
            {
                Current = null;

                if (Cancellation.IsCancellationRequested)
                    History.Clear();
                else
                {
                    if (!TestFailed)
                    {
                        if (!Settings.Default.HideReportForm)
                            OnlineReport();
                    }
                }
            }
        }
Beispiel #8
0
 private void OnException(Exception exception, BenchmarkSession test)
 {
     TestFailed = true;
 }
Beispiel #9
0
        private void DoBenchmark()
        {
            //CurrentTest = new BenchmarkSuite();
            //CurrentTest.ExecuteTests(TableCount, RecordCount, Randomness, Cancellation, Test);

            // TODO: Fix this.
            //testSuite.OnTestMethodCompleted += Report;
            //testSuite.OnException += OnException;

            try
            {
                foreach (var benchmark in History)
                {
                    if (Cancellation.IsCancellationRequested)
                    {
                        break;
                    }

                    //Current = benchmark;
                    //testSuite.ExecuteInit(benchmark);

                    //// Write.
                    //MainLayout.SetCurrentMethod(TestMethod.Write);
                    //CurrentStatus = TestMethod.Write.ToString();

                    //testSuite.ExecuteWrite(benchmark);

                    //// Read.
                    //MainLayout.SetCurrentMethod(TestMethod.Read);
                    //CurrentStatus = TestMethod.Read.ToString();

                    //testSuite.ExecuteRead(benchmark);

                    //// Secondary Read.
                    //MainLayout.SetCurrentMethod(TestMethod.SecondaryRead);
                    //CurrentStatus = TestMethod.SecondaryRead.ToString();

                    //testSuite.ExecuteSecondaryRead(benchmark);

                    //// Finish.
                    //CurrentStatus = TestMethod.None.ToString();
                    //testSuite.ExecuteFinish(benchmark);
                }
            }
            finally
            {
                Current = null;

                if (Cancellation.IsCancellationRequested)
                {
                    History.Clear();
                }
                else
                {
                    if (!TestFailed)
                    {
                        if (!Settings.Default.HideReportForm)
                        {
                            OnlineReport();
                        }
                    }
                }
            }
        }