diff --git a/crates/aiken-lang/src/test_framework.rs b/crates/aiken-lang/src/test_framework.rs index 33305d47..85131125 100644 --- a/crates/aiken-lang/src/test_framework.rs +++ b/crates/aiken-lang/src/test_framework.rs @@ -523,7 +523,7 @@ impl Benchmark { prng = new_prng; let mut eval_result = self.eval(&value, plutus_version); results.push(BenchmarkResult { - test: self.clone(), + bench: self.clone(), cost: eval_result.cost(), success: true, traces: eval_result.logs().to_vec(), @@ -536,7 +536,7 @@ impl Benchmark { Err(e) => { results.push(BenchmarkResult { - test: self.clone(), + bench: self.clone(), cost: ExBudget::default(), success: false, traces: vec![e.to_string()], @@ -1068,7 +1068,7 @@ where pub enum TestResult { UnitTestResult(UnitTestResult), PropertyTestResult(PropertyTestResult), - Benchmark(BenchmarkResult), + BenchmarkResult(BenchmarkResult), } unsafe impl Send for TestResult {} @@ -1083,7 +1083,7 @@ impl TestResult<(Constant, Rc), PlutusData> { TestResult::PropertyTestResult(test) => { TestResult::PropertyTestResult(test.reify(data_types)) } - TestResult::Benchmark(result) => TestResult::Benchmark(result), + TestResult::BenchmarkResult(result) => TestResult::BenchmarkResult(result), } } } @@ -1106,7 +1106,7 @@ impl TestResult { } OnTestFailure::SucceedImmediately => counterexample.is_some(), }, - TestResult::Benchmark(BenchmarkResult { success, .. }) => *success, + TestResult::BenchmarkResult(BenchmarkResult { success, .. }) => *success, } } @@ -1116,7 +1116,7 @@ impl TestResult { TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => { test.module.as_str() } - TestResult::Benchmark(BenchmarkResult { ref test, .. }) => test.module.as_str(), + TestResult::BenchmarkResult(BenchmarkResult { ref bench, .. }) => bench.module.as_str(), } } @@ -1126,7 +1126,7 @@ impl TestResult { TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => { test.name.as_str() } - TestResult::Benchmark(BenchmarkResult { ref test, .. }) => test.name.as_str(), + TestResult::BenchmarkResult(BenchmarkResult { ref bench, .. }) => bench.name.as_str(), } } @@ -1134,7 +1134,7 @@ impl TestResult { match self { TestResult::UnitTestResult(UnitTestResult { traces, .. }) | TestResult::PropertyTestResult(PropertyTestResult { traces, .. }) - | TestResult::Benchmark(BenchmarkResult { traces, .. }) => traces, + | TestResult::BenchmarkResult(BenchmarkResult { traces, .. }) => traces, } } } @@ -1472,7 +1472,7 @@ impl Assertion { #[derive(Debug, Clone)] pub struct BenchmarkResult { - pub test: Benchmark, + pub bench: Benchmark, pub cost: ExBudget, pub success: bool, pub traces: Vec, diff --git a/crates/aiken-project/src/error.rs b/crates/aiken-project/src/error.rs index 97e99aea..656e19f8 100644 --- a/crates/aiken-project/src/error.rs +++ b/crates/aiken-project/src/error.rs @@ -193,7 +193,7 @@ impl Error { test.input_path.to_path_buf(), test.program.to_pretty(), ), - TestResult::Benchmark(_) => ("bench".to_string(), PathBuf::new(), String::new()), // todo + TestResult::BenchmarkResult(_) => ("bench".to_string(), PathBuf::new(), String::new()), // todo }; Error::TestFailure { diff --git a/crates/aiken-project/src/lib.rs b/crates/aiken-project/src/lib.rs index e9d41bb3..a1c14719 100644 --- a/crates/aiken-project/src/lib.rs +++ b/crates/aiken-project/src/lib.rs @@ -1135,7 +1135,7 @@ where Test::Benchmark(benchmark) => benchmark .benchmark(seed, property_max_success, plutus_version) .into_iter() - .map(TestResult::Benchmark) + .map(TestResult::BenchmarkResult) .collect::>(), }) .collect::), PlutusData>>>() diff --git a/crates/aiken-project/src/telemetry.rs b/crates/aiken-project/src/telemetry.rs index 6e49b7c9..94491c43 100644 --- a/crates/aiken-project/src/telemetry.rs +++ b/crates/aiken-project/src/telemetry.rs @@ -134,7 +134,7 @@ pub(crate) fn find_max_execution_units(xs: &[TestResult]) -> (usize, us (max_mem, max_cpu, max_iter) } } - TestResult::Benchmark(..) => { + TestResult::BenchmarkResult(..) => { unreachable!("property returned benchmark result ?!") } }); diff --git a/crates/aiken-project/src/telemetry/json.rs b/crates/aiken-project/src/telemetry/json.rs index 4b9f807a..b72e7b87 100644 --- a/crates/aiken-project/src/telemetry/json.rs +++ b/crates/aiken-project/src/telemetry/json.rs @@ -43,10 +43,10 @@ impl EventListener for Json { let benchmark_results: Vec<_> = tests .into_iter() .filter_map(|test| { - if let TestResult::Benchmark(result) = test { + if let TestResult::BenchmarkResult(result) = test { Some(serde_json::json!({ - "name": result.test.name, - "module": result.test.module, + "name": result.bench.name, + "module": result.bench.module, "memory": result.cost.mem, "cpu": result.cost.cpu })) @@ -74,7 +74,7 @@ fn fmt_test_json(result: &TestResult) -> serde_json::V TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => { &test.on_test_failure } - TestResult::Benchmark(_) => unreachable!("benchmark returned in JSON output"), + TestResult::BenchmarkResult(_) => unreachable!("benchmark returned in JSON output"), }; let mut test = json!({ @@ -120,7 +120,7 @@ fn fmt_test_json(result: &TestResult) -> serde_json::V Err(err) => json!({"error": err.to_string()}), }; } - TestResult::Benchmark(_) => unreachable!("benchmark returned in JSON output"), + TestResult::BenchmarkResult(_) => unreachable!("benchmark returned in JSON output"), } if !result.traces().is_empty() { diff --git a/crates/aiken-project/src/telemetry/terminal.rs b/crates/aiken-project/src/telemetry/terminal.rs index c234f944..d0dfd698 100644 --- a/crates/aiken-project/src/telemetry/terminal.rs +++ b/crates/aiken-project/src/telemetry/terminal.rs @@ -226,8 +226,8 @@ impl EventListener for Terminal { } Event::FinishedBenchmarks { tests, .. } => { for test in tests { - if let TestResult::Benchmark(result) = test { - println!("{} {} ", result.test.name.bold(), "BENCH".blue(),); + if let TestResult::BenchmarkResult(result) = test { + println!("{} {} ", result.bench.name.bold(), "BENCH".blue(),); println!(" Memory: {} bytes", result.cost.mem); println!(" CPU: {} units", result.cost.cpu); println!(); @@ -292,7 +292,7 @@ fn fmt_test( if *iterations > 1 { "s" } else { "" } ); } - TestResult::Benchmark(benchmark) => { + TestResult::BenchmarkResult(benchmark) => { let mem_pad = pretty::pad_left(benchmark.cost.mem.to_string(), max_mem, " "); let cpu_pad = pretty::pad_left(benchmark.cost.cpu.to_string(), max_cpu, " "); diff --git a/crates/aiken-project/src/test_framework.rs b/crates/aiken-project/src/test_framework.rs index bf5f744b..f8e2dc7f 100644 --- a/crates/aiken-project/src/test_framework.rs +++ b/crates/aiken-project/src/test_framework.rs @@ -278,7 +278,9 @@ mod test { PropertyTest::DEFAULT_MAX_SUCCESS, &PlutusVersion::default(), ) { - TestResult::UnitTestResult(..) => unreachable!("property returned unit-test result ?!"), + TestResult::BenchmarkResult(..) | TestResult::UnitTestResult(..) => { + unreachable!("property returned non-property result ?!") + } TestResult::PropertyTestResult(result) => { assert!( result @@ -289,7 +291,6 @@ mod test { result.labels ) } - TestResult::Benchmark(..) => unreachable!("property returned benchmark result ?!"), } }