fixup aesthetics
Signed-off-by: KtorZ <5680256+KtorZ@users.noreply.github.com>
This commit is contained in:
parent
2a1253cb52
commit
37f721ff06
|
@ -523,7 +523,7 @@ impl Benchmark {
|
||||||
prng = new_prng;
|
prng = new_prng;
|
||||||
let mut eval_result = self.eval(&value, plutus_version);
|
let mut eval_result = self.eval(&value, plutus_version);
|
||||||
results.push(BenchmarkResult {
|
results.push(BenchmarkResult {
|
||||||
test: self.clone(),
|
bench: self.clone(),
|
||||||
cost: eval_result.cost(),
|
cost: eval_result.cost(),
|
||||||
success: true,
|
success: true,
|
||||||
traces: eval_result.logs().to_vec(),
|
traces: eval_result.logs().to_vec(),
|
||||||
|
@ -536,7 +536,7 @@ impl Benchmark {
|
||||||
|
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
results.push(BenchmarkResult {
|
results.push(BenchmarkResult {
|
||||||
test: self.clone(),
|
bench: self.clone(),
|
||||||
cost: ExBudget::default(),
|
cost: ExBudget::default(),
|
||||||
success: false,
|
success: false,
|
||||||
traces: vec![e.to_string()],
|
traces: vec![e.to_string()],
|
||||||
|
@ -1068,7 +1068,7 @@ where
|
||||||
pub enum TestResult<U, T> {
|
pub enum TestResult<U, T> {
|
||||||
UnitTestResult(UnitTestResult<U>),
|
UnitTestResult(UnitTestResult<U>),
|
||||||
PropertyTestResult(PropertyTestResult<T>),
|
PropertyTestResult(PropertyTestResult<T>),
|
||||||
Benchmark(BenchmarkResult),
|
BenchmarkResult(BenchmarkResult),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<U, T> Send for TestResult<U, T> {}
|
unsafe impl<U, T> Send for TestResult<U, T> {}
|
||||||
|
@ -1083,7 +1083,7 @@ impl TestResult<(Constant, Rc<Type>), PlutusData> {
|
||||||
TestResult::PropertyTestResult(test) => {
|
TestResult::PropertyTestResult(test) => {
|
||||||
TestResult::PropertyTestResult(test.reify(data_types))
|
TestResult::PropertyTestResult(test.reify(data_types))
|
||||||
}
|
}
|
||||||
TestResult::Benchmark(result) => TestResult::Benchmark(result),
|
TestResult::BenchmarkResult(result) => TestResult::BenchmarkResult(result),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1106,7 +1106,7 @@ impl<U, T> TestResult<U, T> {
|
||||||
}
|
}
|
||||||
OnTestFailure::SucceedImmediately => counterexample.is_some(),
|
OnTestFailure::SucceedImmediately => counterexample.is_some(),
|
||||||
},
|
},
|
||||||
TestResult::Benchmark(BenchmarkResult { success, .. }) => *success,
|
TestResult::BenchmarkResult(BenchmarkResult { success, .. }) => *success,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,7 +1116,7 @@ impl<U, T> TestResult<U, T> {
|
||||||
TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => {
|
TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => {
|
||||||
test.module.as_str()
|
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<U, T> TestResult<U, T> {
|
||||||
TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => {
|
TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => {
|
||||||
test.name.as_str()
|
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<U, T> TestResult<U, T> {
|
||||||
match self {
|
match self {
|
||||||
TestResult::UnitTestResult(UnitTestResult { traces, .. })
|
TestResult::UnitTestResult(UnitTestResult { traces, .. })
|
||||||
| TestResult::PropertyTestResult(PropertyTestResult { traces, .. })
|
| TestResult::PropertyTestResult(PropertyTestResult { traces, .. })
|
||||||
| TestResult::Benchmark(BenchmarkResult { traces, .. }) => traces,
|
| TestResult::BenchmarkResult(BenchmarkResult { traces, .. }) => traces,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1472,7 +1472,7 @@ impl Assertion<UntypedExpr> {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct BenchmarkResult {
|
pub struct BenchmarkResult {
|
||||||
pub test: Benchmark,
|
pub bench: Benchmark,
|
||||||
pub cost: ExBudget,
|
pub cost: ExBudget,
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
pub traces: Vec<String>,
|
pub traces: Vec<String>,
|
||||||
|
|
|
@ -193,7 +193,7 @@ impl Error {
|
||||||
test.input_path.to_path_buf(),
|
test.input_path.to_path_buf(),
|
||||||
test.program.to_pretty(),
|
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 {
|
Error::TestFailure {
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ where
|
||||||
Test::Benchmark(benchmark) => benchmark
|
Test::Benchmark(benchmark) => benchmark
|
||||||
.benchmark(seed, property_max_success, plutus_version)
|
.benchmark(seed, property_max_success, plutus_version)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(TestResult::Benchmark)
|
.map(TestResult::BenchmarkResult)
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
})
|
})
|
||||||
.collect::<Vec<TestResult<(Constant, Rc<Type>), PlutusData>>>()
|
.collect::<Vec<TestResult<(Constant, Rc<Type>), PlutusData>>>()
|
||||||
|
|
|
@ -134,7 +134,7 @@ pub(crate) fn find_max_execution_units<T>(xs: &[TestResult<T, T>]) -> (usize, us
|
||||||
(max_mem, max_cpu, max_iter)
|
(max_mem, max_cpu, max_iter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TestResult::Benchmark(..) => {
|
TestResult::BenchmarkResult(..) => {
|
||||||
unreachable!("property returned benchmark result ?!")
|
unreachable!("property returned benchmark result ?!")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,10 +43,10 @@ impl EventListener for Json {
|
||||||
let benchmark_results: Vec<_> = tests
|
let benchmark_results: Vec<_> = tests
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|test| {
|
.filter_map(|test| {
|
||||||
if let TestResult::Benchmark(result) = test {
|
if let TestResult::BenchmarkResult(result) = test {
|
||||||
Some(serde_json::json!({
|
Some(serde_json::json!({
|
||||||
"name": result.test.name,
|
"name": result.bench.name,
|
||||||
"module": result.test.module,
|
"module": result.bench.module,
|
||||||
"memory": result.cost.mem,
|
"memory": result.cost.mem,
|
||||||
"cpu": result.cost.cpu
|
"cpu": result.cost.cpu
|
||||||
}))
|
}))
|
||||||
|
@ -74,7 +74,7 @@ fn fmt_test_json(result: &TestResult<UntypedExpr, UntypedExpr>) -> serde_json::V
|
||||||
TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => {
|
TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => {
|
||||||
&test.on_test_failure
|
&test.on_test_failure
|
||||||
}
|
}
|
||||||
TestResult::Benchmark(_) => unreachable!("benchmark returned in JSON output"),
|
TestResult::BenchmarkResult(_) => unreachable!("benchmark returned in JSON output"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut test = json!({
|
let mut test = json!({
|
||||||
|
@ -120,7 +120,7 @@ fn fmt_test_json(result: &TestResult<UntypedExpr, UntypedExpr>) -> serde_json::V
|
||||||
Err(err) => json!({"error": err.to_string()}),
|
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() {
|
if !result.traces().is_empty() {
|
||||||
|
|
|
@ -226,8 +226,8 @@ impl EventListener for Terminal {
|
||||||
}
|
}
|
||||||
Event::FinishedBenchmarks { tests, .. } => {
|
Event::FinishedBenchmarks { tests, .. } => {
|
||||||
for test in tests {
|
for test in tests {
|
||||||
if let TestResult::Benchmark(result) = test {
|
if let TestResult::BenchmarkResult(result) = test {
|
||||||
println!("{} {} ", result.test.name.bold(), "BENCH".blue(),);
|
println!("{} {} ", result.bench.name.bold(), "BENCH".blue(),);
|
||||||
println!(" Memory: {} bytes", result.cost.mem);
|
println!(" Memory: {} bytes", result.cost.mem);
|
||||||
println!(" CPU: {} units", result.cost.cpu);
|
println!(" CPU: {} units", result.cost.cpu);
|
||||||
println!();
|
println!();
|
||||||
|
@ -292,7 +292,7 @@ fn fmt_test(
|
||||||
if *iterations > 1 { "s" } else { "" }
|
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 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, " ");
|
let cpu_pad = pretty::pad_left(benchmark.cost.cpu.to_string(), max_cpu, " ");
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,9 @@ mod test {
|
||||||
PropertyTest::DEFAULT_MAX_SUCCESS,
|
PropertyTest::DEFAULT_MAX_SUCCESS,
|
||||||
&PlutusVersion::default(),
|
&PlutusVersion::default(),
|
||||||
) {
|
) {
|
||||||
TestResult::UnitTestResult(..) => unreachable!("property returned unit-test result ?!"),
|
TestResult::BenchmarkResult(..) | TestResult::UnitTestResult(..) => {
|
||||||
|
unreachable!("property returned non-property result ?!")
|
||||||
|
}
|
||||||
TestResult::PropertyTestResult(result) => {
|
TestResult::PropertyTestResult(result) => {
|
||||||
assert!(
|
assert!(
|
||||||
result
|
result
|
||||||
|
@ -289,7 +291,6 @@ mod test {
|
||||||
result.labels
|
result.labels
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
TestResult::Benchmark(..) => unreachable!("property returned benchmark result ?!"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue