Skip to content

Commit

Permalink
metric_value
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed Sep 25, 2023
1 parent fbe8825 commit 9dd63a2
Show file tree
Hide file tree
Showing 33 changed files with 342 additions and 265 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ heading: "Bencher Changelog"
sortOrder: 4
---

## Pending `v0.3.12`
- Change Metric `lower_bound` and `upper_bound` to `lower_value` and `upper_value` respectively

## `v0.3.11`
- Add strongly typed IDs for database entities
- Remove deprecated configuration keys (`endpoint` => `console.url` and `secret_key` => `security.secret_key`)
Expand Down
16 changes: 8 additions & 8 deletions lib/bencher_adapter/benches/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ const JSON_RESULT: &str = r#"{
"tests::benchmark_1": {
"latency": {
"value": 1.0,
"lower_bound": 1.0,
"upper_bound": 1.0
"lower_value": 1.0,
"upper_value": 1.0
}
},
"tests::benchmark_2": {
"latency": {
"value": 22.0,
"lower_bound": 22.0,
"upper_bound": 22.0
"lower_value": 22.0,
"upper_value": 22.0
}
},
"tests::benchmark_3": {
"latency": {
"value": 333.0,
"lower_bound": 333.0,
"upper_bound": 333.0
"lower_value": 333.0,
"upper_value": 333.0
}
},
"tests::benchmark_4": {
"latency": {
"value": 4444.0,
"lower_bound": 4444.0,
"upper_bound": 4444.0
"lower_value": 4444.0,
"upper_value": 4444.0
}
}
}"#;
Expand Down
6 changes: 3 additions & 3 deletions lib/bencher_adapter/src/adapters/c_sharp/dot_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ impl DotNet {
JsonAverage::Median => (median, interquartile_range),
};
let value = latency_as_nanos(average, units);
let bound = latency_as_nanos(spread, units);
let spread = latency_as_nanos(spread, units);
let json_metric = JsonMetric {
value,
lower_bound: Some(value - bound),
upper_bound: Some(value + bound),
lower_value: Some(value - spread),
upper_value: Some(value + spread),
};

benchmark_metrics.push((benchmark_name, json_metric));
Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_adapter/src/adapters/cpp/catch2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ fn parse_catch2<'i>(
if benchmark_name_remainder.is_empty() && mean_remainder.is_empty() {
let json_metric = JsonMetric {
value: mean,
lower_bound: Some(mean - std_dev),
upper_bound: Some(mean + std_dev),
lower_value: Some(mean - std_dev),
upper_value: Some(mean + std_dev),
};

Ok((benchmark_name, json_metric))
Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_adapter/src/adapters/cpp/google.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ impl TryFrom<Google> for Option<AdapterResults> {
let value = latency_as_nanos(real_time, time_unit);
let json_metric = JsonMetric {
value,
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
};

benchmark_metrics.push((name, json_metric));
Expand Down
28 changes: 14 additions & 14 deletions lib/bencher_adapter/src/adapters/go/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ fn parse_go_bench(input: &str) -> IResult<&str, JsonMetric> {
let value = latency_as_nanos(duration, units);
Ok(JsonMetric {
value,
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
})
},
)(input)
Expand Down Expand Up @@ -105,8 +105,8 @@ pub(crate) mod test_go_bench {
"BenchmarkFib10-8".parse().unwrap(),
JsonMetric {
value: 325.0.into(),
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
},
),
)),
Expand All @@ -119,8 +119,8 @@ pub(crate) mod test_go_bench {
"BenchmarkFib20".parse().unwrap(),
JsonMetric {
value: 40_537.123.into(),
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
},
),
)),
Expand All @@ -133,8 +133,8 @@ pub(crate) mod test_go_bench {
"BenchmarkFib/my_tabled_benchmark_-_10-8".parse().unwrap(),
JsonMetric {
value: 325.0.into(),
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
},
),
)),
Expand All @@ -147,8 +147,8 @@ pub(crate) mod test_go_bench {
"BenchmarkFib/my_tabled_benchmark_-_20".parse().unwrap(),
JsonMetric {
value: 40_537.123.into(),
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
},
),
)),
Expand All @@ -161,8 +161,8 @@ pub(crate) mod test_go_bench {
"BenchmarkFib/my/tabled/benchmark_-_20".parse().unwrap(),
JsonMetric {
value: 40_537.456.into(),
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
},
),
)),
Expand All @@ -175,8 +175,8 @@ pub(crate) mod test_go_bench {
"BenchmarkFib20WithAuxMetric-8".parse().unwrap(),
JsonMetric {
value: 25_829.0.into(),
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
},
),
)),
Expand Down
16 changes: 8 additions & 8 deletions lib/bencher_adapter/src/adapters/java/jmh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ impl TryFrom<Jmh> for Option<AdapterResults> {

let time_unit = unit.parse()?;
let value = latency_as_nanos(score, time_unit);
let lower_bound = latency_as_nanos(score_confidence.0, time_unit);
let upper_bound = latency_as_nanos(score_confidence.1, time_unit);
let lower_value = latency_as_nanos(score_confidence.0, time_unit);
let upper_value = latency_as_nanos(score_confidence.1, time_unit);
let json_metric = JsonMetric {
value,
lower_bound: Some(lower_bound),
upper_bound: Some(upper_bound),
lower_value: Some(lower_value),
upper_value: Some(upper_value),
};
AdapterMetricKind::Latency(json_metric)
} else if let Some((ops_slash, unit)) = score_unit.split_once("ops/") {
Expand All @@ -88,12 +88,12 @@ impl TryFrom<Jmh> for Option<AdapterResults> {

let time_unit = unit.parse()?;
let value = throughput_as_secs(score, time_unit);
let lower_bound = throughput_as_secs(score_confidence.0, time_unit);
let upper_bound = throughput_as_secs(score_confidence.1, time_unit);
let lower_value = throughput_as_secs(score_confidence.0, time_unit);
let upper_value = throughput_as_secs(score_confidence.1, time_unit);
let json_metric = JsonMetric {
value,
lower_bound: Some(lower_bound),
upper_bound: Some(upper_bound),
lower_value: Some(lower_value),
upper_value: Some(upper_value),
};
AdapterMetricKind::Throughput(json_metric)
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_adapter/src/adapters/js/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ fn parse_benchmark_time(input: &str) -> IResult<&str, JsonMetric> {
let error = value * percent_error;
JsonMetric {
value,
lower_bound: Some(value - error),
upper_bound: Some(value + error),
lower_value: Some(value - error),
upper_value: Some(value + error),
}
},
)(input)
Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_adapter/src/adapters/js/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ fn parse_time_time(input: &str) -> IResult<&str, JsonMetric> {
let value = latency_as_nanos(duration, units);
JsonMetric {
value,
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
}
},
)(input)
Expand Down
22 changes: 11 additions & 11 deletions lib/bencher_adapter/src/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,38 @@ pub(crate) mod test_util {
pub fn validate_latency(
metrics: &AdapterMetrics,
value: f64,
lower_bound: Option<f64>,
upper_bound: Option<f64>,
lower_value: Option<f64>,
upper_value: Option<f64>,
) {
validate_metric(metrics, LATENCY_SLUG_STR, value, lower_bound, upper_bound);
validate_metric(metrics, LATENCY_SLUG_STR, value, lower_value, upper_value);
}

pub fn validate_throughput(
metrics: &AdapterMetrics,
value: f64,
lower_bound: Option<f64>,
upper_bound: Option<f64>,
lower_value: Option<f64>,
upper_value: Option<f64>,
) {
validate_metric(
metrics,
THROUGHPUT_SLUG_STR,
value,
lower_bound,
upper_bound,
lower_value,
upper_value,
);
}

pub fn validate_metric(
metrics: &AdapterMetrics,
key: &str,
value: f64,
lower_bound: Option<f64>,
upper_bound: Option<f64>,
lower_value: Option<f64>,
upper_value: Option<f64>,
) {
assert_eq!(metrics.inner.len(), 1);
let metric = metrics.get(key).unwrap();
assert_eq!(metric.value, OrderedFloat::from(value));
assert_eq!(metric.lower_bound, lower_bound.map(OrderedFloat::from));
assert_eq!(metric.upper_bound, upper_bound.map(OrderedFloat::from));
assert_eq!(metric.lower_value, lower_value.map(OrderedFloat::from));
assert_eq!(metric.upper_value, upper_value.map(OrderedFloat::from));
}
}
6 changes: 3 additions & 3 deletions lib/bencher_adapter/src/adapters/python/asv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ fn parse_asv_time(input: &str) -> IResult<&str, JsonMetric> {
tuple((parse_f64, tag("±"), parse_f64, parse_units, eof)),
|(duration, _, range, units, _)| {
let value = latency_as_nanos(duration, units);
let bound = latency_as_nanos(range, units);
let range = latency_as_nanos(range, units);
JsonMetric {
value,
lower_bound: Some(value - bound),
upper_bound: Some(value + bound),
lower_value: Some(value - range),
upper_value: Some(value + range),
}
},
)(input)
Expand Down
6 changes: 3 additions & 3 deletions lib/bencher_adapter/src/adapters/python/pytest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ impl Pytest {
JsonAverage::Median => (median, iqr),
};
let value = latency_as_nanos(average, units);
let bound = latency_as_nanos(spread, units);
let spread = latency_as_nanos(spread, units);
let json_metric = JsonMetric {
value,
lower_bound: Some(value - bound),
upper_bound: Some(value + bound),
lower_value: Some(value - spread),
upper_value: Some(value + spread),
};

benchmark_metrics.push((benchmark_name, json_metric));
Expand Down
4 changes: 2 additions & 2 deletions lib/bencher_adapter/src/adapters/ruby/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ fn parse_ruby_benchmark(input: &str) -> IResult<&str, JsonMetric> {
let value = latency_as_nanos(real, units);
Ok(JsonMetric {
value,
lower_bound: None,
upper_bound: None,
lower_value: None,
upper_value: None,
})
},
)(input)
Expand Down
8 changes: 4 additions & 4 deletions lib/bencher_adapter/src/adapters/rust/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ fn parse_cargo_bench(input: &str) -> IResult<&str, JsonMetric> {
let variance = Some(latency_as_nanos(variance, units));
JsonMetric {
value,
lower_bound: variance.map(|v| value - v),
upper_bound: variance.map(|v| value + v),
lower_value: variance.map(|v| value - v),
upper_value: variance.map(|v| value + v),
}
},
)(input)
Expand Down Expand Up @@ -145,8 +145,8 @@ pub(crate) mod test_rust_bench {
"tests::is_bench_test".parse().unwrap(),
JsonMetric {
value: 5_280.0.into(),
lower_bound: Some(4_947.0.into()),
upper_bound: Some(5_613.0.into()),
lower_value: Some(4_947.0.into()),
upper_value: Some(5_613.0.into()),
},
),
)),
Expand Down
18 changes: 9 additions & 9 deletions lib/bencher_adapter/src/adapters/rust/criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ fn parse_criterion_metric(input: &str) -> IResult<&str, JsonMetric> {
)),
tag("]"),
),
|(lower_bound, _, value, _, upper_bound)| JsonMetric {
|(lower_value, _, value, _, upper_value)| JsonMetric {
value,
lower_bound: Some(lower_bound),
upper_bound: Some(upper_bound),
lower_value: Some(lower_value),
upper_value: Some(upper_value),
},
)(input)
}
Expand Down Expand Up @@ -128,8 +128,8 @@ pub(crate) mod test_rust_criterion {
"criterion_benchmark".parse().unwrap(),
JsonMetric {
value: 280.0.into(),
lower_bound: Some(222.2.into()),
upper_bound: Some(333.33.into()),
lower_value: Some(222.2.into()),
upper_value: Some(333.33.into()),
},
),
)),
Expand All @@ -142,8 +142,8 @@ pub(crate) mod test_rust_criterion {
"criterion_benchmark".parse().unwrap(),
JsonMetric {
value: 5.280.into(),
lower_bound: Some(0.222.into()),
upper_bound: Some(0.33333.into()),
lower_value: Some(0.222.into()),
upper_value: Some(0.33333.into()),
},
),
)),
Expand All @@ -156,8 +156,8 @@ pub(crate) mod test_rust_criterion {
"criterion_benchmark".parse().unwrap(),
JsonMetric {
value: 18_019.0.into(),
lower_bound: Some(16_652.0.into()),
upper_bound: Some(19_562.0.into()),
lower_value: Some(16_652.0.into()),
upper_value: Some(19_562.0.into()),
},
),
)),
Expand Down
Loading

0 comments on commit 9dd63a2

Please sign in to comment.