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); } }
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); }