public static void ExportSummaryTestResults(List <BenchmarkTest> sessions, string path)
        {
            // ---Write Summary File---
            //#time
            //#database;write speed (rec/sec);read speed;secondary read speed;size (MB)

            string extension = ".csv";

            string[] fullPath        = path.Split(new string[] { extension }, StringSplitOptions.None);
            string   summaryFileName = fullPath[0] + ".summary" + extension;

            using (StreamWriter writer = new StreamWriter(summaryFileName))
            {
                // write settings
                ExportSettings(writer, sessions[0]);

                // write computer configuration
                writer.WriteLine();
                ExportComputerConfiguration(writer, SystemUtils.GetComputerConfiguration());

                writer.WriteLine();

                // write date
                writer.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH.mm"));
                writer.WriteLine();

                writer.WriteLine(String.Join(";", "Database;Write speed(rec/sec);Read speed(rec/sec);Seconady read speed(rec/sec);Size(MB)"));

                for (int i = 0; i < sessions.Count; i++)
                {
                    BenchmarkTest test = sessions[i];

                    // write database info
                    writer.Write(test.Database.Name + ";");
                    writer.Write(test.GetSpeed(TestMethod.Write) + ";");
                    writer.Write(test.GetSpeed(TestMethod.Read) + ";");
                    writer.Write(test.GetSpeed(TestMethod.SecondaryRead) + ";");
                    writer.WriteLine(test.DatabaseSize / (1024.0 * 1024.0) + ";");
                }
            }
        }
Beispiel #2
0
        private void Report(BenchmarkTest benchmark, TestMethod method)
        {
            try
            {
                Action <string, object, Color> updateChart = null;

                StepFrame ActiveStepFrame = ApplicationManager.GetCurrentStepFrame();
                string    databaseName    = benchmark.Database.Name;
                Color     databaseColor   = benchmark.Database.Color;

                // Speed chart.
                updateChart = ActiveStepFrame.AddAverageSpeedToBar;
                Report(databaseName, databaseColor, updateChart, benchmark.GetSpeed(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.GetTime(method).Ticks));

                // CPU chart.
                //updateChart = ActiveStepFrame.AddCpuUsageToBar;
                //Report(databaseName, databaseColor, updateChart, benchmark.GetAverageProcessorTime(method));

                // Memory chart.
                updateChart = ActiveStepFrame.AddMemoryUsageToBar;
                Report(databaseName, databaseColor, updateChart, benchmark.GetPeakWorkingSet(method) / (1024.0 * 1024.0));

                // I/O chart.
                //updateChart = ActiveStepFrame.AddIoUsageToBar;
                //Report(databaseName, databaseColor, updateChart, benchmark.GetAverageIOData(method) / (1024.0 * 1024.0));
            }
            catch (Exception exc)
            {
                Logger.Error("Report results failed...", exc);
            }
        }
Beispiel #3
0
        public static JsonObjectCollection ConvertToJson(BenchmarkTest benchmark, ReportType type)
        {
            JsonObjectCollection jsonBenchmark = new JsonObjectCollection("BenchmarkTest");

            // Test info parameters.
            JsonObjectCollection jsonSettings = new JsonObjectCollection("TestInfo");

            jsonSettings.Add(new JsonNumericValue("FlowCount", benchmark.FlowCount));
            jsonSettings.Add(new JsonNumericValue("RecordCount", benchmark.RecordCount));
            jsonSettings.Add(new JsonNumericValue("Randomness", benchmark.Randomness * 100));

            long elapsedTime = benchmark.EndTime.Ticks - benchmark.StartTime.Ticks;

            jsonSettings.Add(new JsonNumericValue("ElapsedTime", new TimeSpan(elapsedTime).TotalMilliseconds));

            JsonObjectCollection jsonDatabase = new JsonObjectCollection("Database");

            jsonDatabase.Add(new JsonStringValue("Name", benchmark.Database.Name));
            jsonDatabase.Add(new JsonStringValue("IndexingTechnology", benchmark.Database.IndexingTechnology.ToString()));
            jsonDatabase.Add(new JsonStringValue("Category", benchmark.Database.Name));

            jsonDatabase.Add(new JsonNumericValue("AverageWriteSpeed", benchmark.GetSpeed(TestMethod.Write)));
            jsonDatabase.Add(new JsonNumericValue("AverageReadSpeed", benchmark.GetSpeed(TestMethod.Read)));
            jsonDatabase.Add(new JsonNumericValue("AverageSecondaryReadSpeed", benchmark.GetSpeed(TestMethod.SecondaryRead)));

            jsonDatabase.Add(new JsonNumericValue("WritePeakMemoryUsage", benchmark.GetPeakWorkingSet(TestMethod.Write) / (1024.0 * 1024.0)));
            jsonDatabase.Add(new JsonNumericValue("ReadPeakMemoryUsage", benchmark.GetPeakWorkingSet(TestMethod.Read) / (1024.0 * 1024.0)));
            jsonDatabase.Add(new JsonNumericValue("SecondaryReadPeakMemoryUsage", benchmark.GetPeakWorkingSet(TestMethod.SecondaryRead) / (1024.0 * 1024.0)));

            jsonDatabase.Add(new JsonNumericValue("Size", benchmark.DatabaseSize / (1024.0 * 1024.0)));

            JsonObjectCollection jsonDatabaseSettings = new JsonObjectCollection("Settings");

            if (benchmark.Database.Settings != null)
            {
                foreach (var item in benchmark.Database.Settings)
                {
                    jsonDatabaseSettings.Add(new JsonStringValue(item.Key, item.Value));
                }
            }

            jsonDatabase.Add(jsonDatabaseSettings);

            // Test results.
            JsonObjectCollection jsonTestData      = new JsonObjectCollection("TestResults");
            JsonObject           jsonWrite         = null;
            JsonObject           jsonRead          = null;
            JsonObject           jsonSecondaryRead = null;

            if (type == ReportType.Summary)
            {
                jsonWrite         = new JsonNumericValue("Write", benchmark.GetSpeed(TestMethod.Write));
                jsonRead          = new JsonNumericValue("Read", benchmark.GetSpeed(TestMethod.Read));
                jsonSecondaryRead = new JsonNumericValue("SecondaryRead", benchmark.GetSpeed(TestMethod.SecondaryRead));
            }
            else // type == ReportType.Detailed
            {
                // Get statistics and convert them to JSON.
                SpeedStatistics writeStat         = benchmark.SpeedStatistics[(int)TestMethod.Write];
                SpeedStatistics readStat          = benchmark.SpeedStatistics[(int)TestMethod.Read];
                SpeedStatistics secondaryReadStat = benchmark.SpeedStatistics[(int)TestMethod.SecondaryRead];

                jsonWrite         = ConvertStatisticToJson(writeStat, "Write");
                jsonRead          = ConvertStatisticToJson(readStat, "Read");
                jsonSecondaryRead = ConvertStatisticToJson(secondaryReadStat, "SecondaryRead");
            }

            jsonTestData.Add(jsonWrite);
            jsonTestData.Add(jsonRead);
            jsonTestData.Add(jsonSecondaryRead);

            // Form the end JSON structure.
            jsonBenchmark.Add(jsonSettings);
            jsonBenchmark.Add(jsonDatabase);
            jsonBenchmark.Add(jsonTestData);

            return(jsonBenchmark);
        }