|
3 | 3 |
|
4 | 4 | namespace VirtualClient.Actions |
5 | 5 | { |
| 6 | + using System; |
6 | 7 | using System.Collections.Generic; |
7 | 8 | using System.IO; |
| 9 | + using System.Linq; |
8 | 10 | using System.Reflection; |
9 | 11 | using NUnit.Framework; |
10 | 12 | using VirtualClient; |
@@ -151,6 +153,52 @@ public void SpecCpuMetricsParserParsesExpectedMetricsFromFpRateBaseOnlyCsvResult |
151 | 153 | MetricAssert.Exists(metrics, "SPECrate(R)2017_fp_base", 26.914269, "score"); |
152 | 154 | } |
153 | 155 |
|
| 156 | + [Test] |
| 157 | + public void SpecCpuMetricsParserParsesExpectedBenchmarkMetadataFromFpRateResults() |
| 158 | + { |
| 159 | + string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| 160 | + string outputPath = Path.Combine(workingDirectory, "Examples", "SpecCpu", "SpecCpuFpRateExample.txt"); |
| 161 | + this.rawText = File.ReadAllText(outputPath); |
| 162 | + this.testParser = new SpecCpuMetricsParser(this.rawText); |
| 163 | + |
| 164 | + IList<Metric> metrics = this.testParser.Parse(); |
| 165 | + |
| 166 | + foreach (Metric metric in metrics) |
| 167 | + { |
| 168 | + if (metric.Name.Contains("base")) |
| 169 | + { |
| 170 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "floating_point_base_rate"); |
| 171 | + } |
| 172 | + else if (metric.Name.Contains("peak")) |
| 173 | + { |
| 174 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "floating_point_peak_rate"); |
| 175 | + } |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + [Test] |
| 180 | + public void SpecCpuMetricsParserParsesExpectedBenchmarkMetadataFromFpRateCsvResults() |
| 181 | + { |
| 182 | + string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| 183 | + string outputPath = Path.Combine(workingDirectory, "Examples", "SpecCpu", "SpecCpuFpRateExample.csv"); |
| 184 | + this.rawText = File.ReadAllText(outputPath); |
| 185 | + this.testParser = new SpecCpuMetricsParser(this.rawText, csv: true); |
| 186 | + |
| 187 | + IList<Metric> metrics = this.testParser.Parse(); |
| 188 | + |
| 189 | + foreach (Metric metric in metrics) |
| 190 | + { |
| 191 | + if (metric.Name.Contains("base")) |
| 192 | + { |
| 193 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "floating_point_base_rate"); |
| 194 | + } |
| 195 | + else if (metric.Name.Contains("peak")) |
| 196 | + { |
| 197 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "floating_point_peak_rate"); |
| 198 | + } |
| 199 | + } |
| 200 | + } |
| 201 | + |
154 | 202 | [Test] |
155 | 203 | public void SpecCpuMetricsParserParsesExpectedMetricsFromIntRateBaseOnlyResults() |
156 | 204 | { |
@@ -242,6 +290,52 @@ public void SpecCpuMetricsParserParsesExpectedMetricsFromFpSpeedCsvResults() |
242 | 290 | MetricAssert.Exists(metrics, "SPECspeed(R)2017_fp_peak", 252.731489, "score"); |
243 | 291 | } |
244 | 292 |
|
| 293 | + [Test] |
| 294 | + public void SpecCpuMetricsParserParsesExpectedBenchmarkMetadataFromFpSpeedResults() |
| 295 | + { |
| 296 | + string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| 297 | + string outputPath = Path.Combine(workingDirectory, "Examples", "SpecCpu", "SpecCpuFpSpeedExample.txt"); |
| 298 | + this.rawText = File.ReadAllText(outputPath); |
| 299 | + this.testParser = new SpecCpuMetricsParser(this.rawText); |
| 300 | + |
| 301 | + IList<Metric> metrics = this.testParser.Parse(); |
| 302 | + |
| 303 | + foreach (Metric metric in metrics) |
| 304 | + { |
| 305 | + if (metric.Name.Contains("base")) |
| 306 | + { |
| 307 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "floating_point_base_speed"); |
| 308 | + } |
| 309 | + else if (metric.Name.Contains("peak")) |
| 310 | + { |
| 311 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "floating_point_peak_speed"); |
| 312 | + } |
| 313 | + } |
| 314 | + } |
| 315 | + |
| 316 | + [Test] |
| 317 | + public void SpecCpuMetricsParserParsesExpectedBenchmarkMetadataFromFpSpeedCsvResults() |
| 318 | + { |
| 319 | + string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| 320 | + string outputPath = Path.Combine(workingDirectory, "Examples", "SpecCpu", "SpecCpuFpSpeedExample.csv"); |
| 321 | + this.rawText = File.ReadAllText(outputPath); |
| 322 | + this.testParser = new SpecCpuMetricsParser(this.rawText, csv: true); |
| 323 | + |
| 324 | + IList<Metric> metrics = this.testParser.Parse(); |
| 325 | + |
| 326 | + foreach (Metric metric in metrics) |
| 327 | + { |
| 328 | + if (metric.Name.Contains("base")) |
| 329 | + { |
| 330 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "floating_point_base_speed"); |
| 331 | + } |
| 332 | + else if (metric.Name.Contains("peak")) |
| 333 | + { |
| 334 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "floating_point_peak_speed"); |
| 335 | + } |
| 336 | + } |
| 337 | + } |
| 338 | + |
245 | 339 | [Test] |
246 | 340 | public void SpecCpuMetricsParserParsesExpectedMetricsFromIntRateResults() |
247 | 341 | { |
@@ -310,6 +404,52 @@ public void SpecCpuMetricsParserParsesExpectedMetricsFromIntRateCsvResults() |
310 | 404 | MetricAssert.Exists(metrics, "SPECrate(R)2017_int_peak", 812.169896, "score"); |
311 | 405 | } |
312 | 406 |
|
| 407 | + [Test] |
| 408 | + public void SpecCpuMetricsParserParsesExpectedBenchmarkMetadataFromIntRateResults() |
| 409 | + { |
| 410 | + string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| 411 | + string outputPath = Path.Combine(workingDirectory, "Examples", "SpecCpu", "SpecCpuIntRateExample.txt"); |
| 412 | + this.rawText = File.ReadAllText(outputPath); |
| 413 | + this.testParser = new SpecCpuMetricsParser(this.rawText); |
| 414 | + |
| 415 | + IList<Metric> metrics = this.testParser.Parse(); |
| 416 | + |
| 417 | + foreach (Metric metric in metrics) |
| 418 | + { |
| 419 | + if (metric.Name.Contains("base")) |
| 420 | + { |
| 421 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "integer_base_rate"); |
| 422 | + } |
| 423 | + else if (metric.Name.Contains("peak")) |
| 424 | + { |
| 425 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "integer_peak_rate"); |
| 426 | + } |
| 427 | + } |
| 428 | + } |
| 429 | + |
| 430 | + [Test] |
| 431 | + public void SpecCpuMetricsParserParsesExpectedBenchmarkMetadataFromIntRateCsvResults() |
| 432 | + { |
| 433 | + string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| 434 | + string outputPath = Path.Combine(workingDirectory, "Examples", "SpecCpu", "SpecCpuIntRateExample.csv"); |
| 435 | + this.rawText = File.ReadAllText(outputPath); |
| 436 | + this.testParser = new SpecCpuMetricsParser(this.rawText, csv: true); |
| 437 | + |
| 438 | + IList<Metric> metrics = this.testParser.Parse(); |
| 439 | + |
| 440 | + foreach (Metric metric in metrics) |
| 441 | + { |
| 442 | + if (metric.Name.Contains("base")) |
| 443 | + { |
| 444 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "integer_base_rate"); |
| 445 | + } |
| 446 | + else if (metric.Name.Contains("peak")) |
| 447 | + { |
| 448 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "integer_peak_rate"); |
| 449 | + } |
| 450 | + } |
| 451 | + } |
| 452 | + |
313 | 453 | [Test] |
314 | 454 | public void SpecCpuMetricsParserParsesExpectedMetricsFromIntSpeedResults() |
315 | 455 | { |
@@ -378,6 +518,52 @@ public void SpecCpuMetricsParserParsesExpectedMetricsFromIntSpeedCsvResults() |
378 | 518 | MetricAssert.Exists(metrics, "SPECspeed(R)2017_int_peak", 12.293316, "score"); |
379 | 519 | } |
380 | 520 |
|
| 521 | + [Test] |
| 522 | + public void SpecCpuMetricsParserParsesExpectedBenchmarkMetadataFromIntSpeedResults() |
| 523 | + { |
| 524 | + string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| 525 | + string outputPath = Path.Combine(workingDirectory, "Examples", "SpecCpu", "SpecCpuIntSpeedExample.txt"); |
| 526 | + this.rawText = File.ReadAllText(outputPath); |
| 527 | + this.testParser = new SpecCpuMetricsParser(this.rawText); |
| 528 | + |
| 529 | + IList<Metric> metrics = this.testParser.Parse(); |
| 530 | + |
| 531 | + foreach (Metric metric in metrics) |
| 532 | + { |
| 533 | + if (metric.Name.Contains("base")) |
| 534 | + { |
| 535 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "integer_base_speed"); |
| 536 | + } |
| 537 | + else if (metric.Name.Contains("peak")) |
| 538 | + { |
| 539 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "integer_peak_speed"); |
| 540 | + } |
| 541 | + } |
| 542 | + } |
| 543 | + |
| 544 | + [Test] |
| 545 | + public void SpecCpuMetricsParserParsesExpectedBenchmarkMetadataFromIntSpeedCsvResults() |
| 546 | + { |
| 547 | + string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| 548 | + string outputPath = Path.Combine(workingDirectory, "Examples", "SpecCpu", "SpecCpuIntSpeedExample.csv"); |
| 549 | + this.rawText = File.ReadAllText(outputPath); |
| 550 | + this.testParser = new SpecCpuMetricsParser(this.rawText, csv: true); |
| 551 | + |
| 552 | + IList<Metric> metrics = this.testParser.Parse(); |
| 553 | + |
| 554 | + foreach (Metric metric in metrics) |
| 555 | + { |
| 556 | + if (metric.Name.Contains("base")) |
| 557 | + { |
| 558 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "integer_base_speed"); |
| 559 | + } |
| 560 | + else if (metric.Name.Contains("peak")) |
| 561 | + { |
| 562 | + Assert.IsTrue(metric.Metadata.TryGetValue("workload", out IConvertible workload) && workload.ToString() == "integer_peak_speed"); |
| 563 | + } |
| 564 | + } |
| 565 | + } |
| 566 | + |
381 | 567 | [Test] |
382 | 568 | public void SpecCpuParserVerifyMetricsIntRateBaseWinArm64Incomplete() |
383 | 569 | { |
|
0 commit comments