public static void Main(string[] args) { NetHardwareBench.Benchmark.Main BenchmarkCore = new Benchmark.Main(new Model.Modules.Parameters.ConfigurationParameters() { NetworkPath = "", RemoteEndpoint = "", RemoteIP = "", WorkDirectory = "" }); BenchmarkCore.OnProgressChanged += BenchmarkCore_OnProgressChanged; while (true) { var benchmarkResult = BenchmarkCore .DoBenchmark( BenchmarkType.NETWORK, BenchmarkType.INTERNET, // BenchmarkType.GPU, BenchmarkType.LOCAL_STORAGE, BenchmarkType.RAM, BenchmarkType.CPU ); Console.WriteLine("Benchmark Results"); foreach (var result in benchmarkResult) { Console.WriteLine($"[{result.BenchmarkType.ToString()}]\r\n|- AVG: " + result.Score + " | Score: " + ScoreParser.Calculate(result.BenchmarkType, result.Score) + " %"); switch (result.BenchmarkType) { case BenchmarkType.INTERNET: case BenchmarkType.LOCAL_STORAGE: foreach (var partialresult in result.PartialResults) { Console.WriteLine($" |- {partialresult.Description}: " + partialresult.Score + " | Score: " + ScoreParser.Calculate(result.BenchmarkType, partialresult.Score) + " %"); } break; case BenchmarkType.NETWORK_STORAGE: case BenchmarkType.DATABASE: case BenchmarkType.RAM: case BenchmarkType.NETWORK: case BenchmarkType.CPU: case BenchmarkType.GPU: default: break; } } Console.ReadKey(); } }
private void bwBenchmark_DoWork(object sender, DoWorkEventArgs e) { NetHardwareBench.Benchmark.Main BenchmarkCore = new Benchmark.Main(new Model.Modules.Parameters.ConfigurationParameters() { NetworkPath = "", RemoteEndpoint = "", RemoteIP = "", WorkDirectory = "" }); BenchmarkCore.OnProgressChanged += (double progress) => { lblProgressDescription.Text = $"{Math.Round(progress,0)}%"; this.pbBenchmarkProgress.Value = Convert.ToInt32(progress); }; try { var benchmarkResult = BenchmarkCore .DoBenchmark( BenchmarkType.RAM, BenchmarkType.CPU, BenchmarkType.NETWORK, BenchmarkType.INTERNET, //BenchmarkType.GPU, BenchmarkType.LOCAL_STORAGE); StringBuilder builder = new StringBuilder(); foreach (var item in benchmarkResult) { string calculatedScore = Utils.ScoreParser.Calculate(item.BenchmarkType, item.Score); Image imageScore = GetPictureFromBenchmarkStatus(calculatedScore); builder.AppendLine($"[{item.BenchmarkType.ToString()}]\r\n|- AVG: " + item.Score + " | Score: " + calculatedScore + " %"); switch (item.BenchmarkType) { case BenchmarkType.CPU: pbCPUResult.Image = imageScore; break; case BenchmarkType.GPU: pbGPUResult.Image = imageScore; break; case BenchmarkType.INTERNET: pbInternetResult.Image = imageScore; break; case BenchmarkType.NETWORK: pbNetworkResult.Image = imageScore; break; case BenchmarkType.RAM: pbRamResult.Image = imageScore; break; case BenchmarkType.LOCAL_STORAGE: pbHDDResult.Image = imageScore; break; case BenchmarkType.NETWORK_STORAGE: pbNetworkResult.Image = imageScore; break; } ; switch (item.BenchmarkType) { case BenchmarkType.INTERNET: case BenchmarkType.LOCAL_STORAGE: foreach (var partialresult in item.PartialResults) { builder.AppendLine($" |- {partialresult.Description}: " + partialresult.Score + " | Score: " + Utils.ScoreParser.Calculate(item.BenchmarkType, partialresult.Score) + " %"); } break; } } string JSONResult = JsonConvert.SerializeObject(benchmarkResult, Formatting.Indented); File.WriteAllText(Environment.CurrentDirectory + "\\benchmark_result_summarized.json", builder.ToString()); File.WriteAllText(Environment.CurrentDirectory + "\\benchmark_result_detailed.json", JSONResult); System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\\benchmark_result_summarized.json"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); throw; } }