Skip to content

Commit

Permalink
cleanup_built_in
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed Nov 9, 2024
1 parent 81dd49e commit 2797707
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 191 deletions.
2 changes: 1 addition & 1 deletion lib/bencher_adapter/src/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn print_ln(input: &str) -> IResult<&str, ()> {
pub(crate) mod test_util {
use bencher_json::project::{
measure::built_in::{
generic::{Latency, Throughput},
default::{Latency, Throughput},
BuiltInMeasure,
},
report::JsonAverage,
Expand Down
100 changes: 47 additions & 53 deletions lib/bencher_adapter/src/adapters/rust/iai_callgrind.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use bencher_json::{
project::{
measure::built_in::{
iai_callgrind::{callgrind_tool, dhat_tool},
BuiltInMeasure,
},
measure::built_in::{iai_callgrind, BuiltInMeasure},
report::JsonAverage,
},
BenchmarkName, JsonNewMetric,
Expand Down Expand Up @@ -97,13 +94,13 @@ fn callgrind_tool_measures<'a>() -> impl FnMut(&'a str) -> IResult<&'a str, Vec<
preceded(
opt(tool_name_line("CALLGRIND")),
tuple((
metric_line(callgrind_tool::Instructions::NAME_STR),
metric_line(callgrind_tool::L1Hits::NAME_STR),
metric_line(callgrind_tool::L2Hits::NAME_STR),
metric_line(callgrind_tool::RamHits::NAME_STR),
metric_line(callgrind_tool::TotalReadWrite::NAME_STR),
metric_line(callgrind_tool::EstimatedCycles::NAME_STR),
opt(metric_line(callgrind_tool::GlobalBusEvents::NAME_STR)),
metric_line(iai_callgrind::Instructions::NAME_STR),
metric_line(iai_callgrind::L1Hits::NAME_STR),
metric_line(iai_callgrind::L2Hits::NAME_STR),
metric_line(iai_callgrind::RamHits::NAME_STR),
metric_line(iai_callgrind::TotalReadWrite::NAME_STR),
metric_line(iai_callgrind::EstimatedCycles::NAME_STR),
opt(metric_line(iai_callgrind::GlobalBusEvents::NAME_STR)),
)),
),
|(
Expand Down Expand Up @@ -136,14 +133,14 @@ fn dhat_tool_measures<'a>() -> impl FnMut(&'a str) -> IResult<&'a str, Vec<IaiCa
preceded(
opt(tool_name_line("DHAT")),
tuple((
metric_line(dhat_tool::TotalBytes::NAME_STR),
metric_line(dhat_tool::TotalBlocks::NAME_STR),
metric_line(dhat_tool::AtTGmaxBytes::NAME_STR),
metric_line(dhat_tool::AtTGmaxBlocks::NAME_STR),
metric_line(dhat_tool::AtTEndBytes::NAME_STR),
metric_line(dhat_tool::AtTEndBlocks::NAME_STR),
metric_line(dhat_tool::ReadsBytes::NAME_STR),
metric_line(dhat_tool::WritesBytes::NAME_STR),
metric_line(iai_callgrind::TotalBytes::NAME_STR),
metric_line(iai_callgrind::TotalBlocks::NAME_STR),
metric_line(iai_callgrind::AtTGmaxBytes::NAME_STR),
metric_line(iai_callgrind::AtTGmaxBlocks::NAME_STR),
metric_line(iai_callgrind::AtTEndBytes::NAME_STR),
metric_line(iai_callgrind::AtTEndBlocks::NAME_STR),
metric_line(iai_callgrind::ReadsBytes::NAME_STR),
metric_line(iai_callgrind::WritesBytes::NAME_STR),
)),
),
|(
Expand Down Expand Up @@ -238,10 +235,7 @@ fn not_line_ending<'a>() -> impl FnMut(&'a str) -> IResult<&'a str, &'a str> {
#[cfg(test)]
pub(crate) mod test_rust_iai_callgrind {
use crate::{adapters::test_util::convert_file_path, AdapterResults};
use bencher_json::project::measure::built_in::{
iai_callgrind::{callgrind_tool, dhat_tool},
BuiltInMeasure,
};
use bencher_json::project::measure::built_in::{iai_callgrind, BuiltInMeasure};
use ordered_float::OrderedFloat;
use pretty_assertions::assert_eq;

Expand Down Expand Up @@ -336,28 +330,28 @@ pub(crate) mod test_rust_iai_callgrind {
let mut expected = HashMap::new();

expected.extend([
(callgrind_tool::Instructions::SLUG_STR, 1_734.0),
(callgrind_tool::L1Hits::SLUG_STR, 2_359.0),
(callgrind_tool::L2Hits::SLUG_STR, 0.0),
(callgrind_tool::RamHits::SLUG_STR, 3.0),
(callgrind_tool::TotalReadWrite::SLUG_STR, 2_362.0),
(callgrind_tool::EstimatedCycles::SLUG_STR, 2_464.0),
(iai_callgrind::Instructions::SLUG_STR, 1_734.0),
(iai_callgrind::L1Hits::SLUG_STR, 2_359.0),
(iai_callgrind::L2Hits::SLUG_STR, 0.0),
(iai_callgrind::RamHits::SLUG_STR, 3.0),
(iai_callgrind::TotalReadWrite::SLUG_STR, 2_362.0),
(iai_callgrind::EstimatedCycles::SLUG_STR, 2_464.0),
]);

if optional_metrics.global_bus_events {
expected.insert(callgrind_tool::GlobalBusEvents::SLUG_STR, 2.0);
expected.insert(iai_callgrind::GlobalBusEvents::SLUG_STR, 2.0);
}

if optional_metrics.dhat {
expected.extend([
(dhat_tool::TotalBytes::SLUG_STR, 29_499.0),
(dhat_tool::TotalBlocks::SLUG_STR, 2_806.0),
(dhat_tool::AtTGmaxBytes::SLUG_STR, 378.0),
(dhat_tool::AtTGmaxBlocks::SLUG_STR, 34.0),
(dhat_tool::AtTEndBytes::SLUG_STR, 0.0),
(dhat_tool::AtTEndBlocks::SLUG_STR, 0.0),
(dhat_tool::ReadsBytes::SLUG_STR, 57_725.0),
(dhat_tool::WritesBytes::SLUG_STR, 73_810.0),
(iai_callgrind::TotalBytes::SLUG_STR, 29_499.0),
(iai_callgrind::TotalBlocks::SLUG_STR, 2_806.0),
(iai_callgrind::AtTGmaxBytes::SLUG_STR, 378.0),
(iai_callgrind::AtTGmaxBlocks::SLUG_STR, 34.0),
(iai_callgrind::AtTEndBytes::SLUG_STR, 0.0),
(iai_callgrind::AtTEndBlocks::SLUG_STR, 0.0),
(iai_callgrind::ReadsBytes::SLUG_STR, 57_725.0),
(iai_callgrind::WritesBytes::SLUG_STR, 73_810.0),
]);
}

Expand All @@ -372,28 +366,28 @@ pub(crate) mod test_rust_iai_callgrind {
let mut expected = HashMap::new();

expected.extend([
(callgrind_tool::Instructions::SLUG_STR, 26_214_734.0),
(callgrind_tool::L1Hits::SLUG_STR, 35_638_619.0),
(callgrind_tool::L2Hits::SLUG_STR, 0.0),
(callgrind_tool::RamHits::SLUG_STR, 3.0),
(callgrind_tool::TotalReadWrite::SLUG_STR, 35_638_622.0),
(callgrind_tool::EstimatedCycles::SLUG_STR, 35_638_724.0),
(iai_callgrind::Instructions::SLUG_STR, 26_214_734.0),
(iai_callgrind::L1Hits::SLUG_STR, 35_638_619.0),
(iai_callgrind::L2Hits::SLUG_STR, 0.0),
(iai_callgrind::RamHits::SLUG_STR, 3.0),
(iai_callgrind::TotalReadWrite::SLUG_STR, 35_638_622.0),
(iai_callgrind::EstimatedCycles::SLUG_STR, 35_638_724.0),
]);

if optional_metrics.global_bus_events {
expected.insert(callgrind_tool::GlobalBusEvents::SLUG_STR, 10.0);
expected.insert(iai_callgrind::GlobalBusEvents::SLUG_STR, 10.0);
}

if optional_metrics.dhat {
expected.extend([
(dhat_tool::TotalBytes::SLUG_STR, 26_294_939.0),
(dhat_tool::TotalBlocks::SLUG_STR, 2_328_086.0),
(dhat_tool::AtTGmaxBytes::SLUG_STR, 933_718.0),
(dhat_tool::AtTGmaxBlocks::SLUG_STR, 18_344.0),
(dhat_tool::AtTEndBytes::SLUG_STR, 0.0),
(dhat_tool::AtTEndBlocks::SLUG_STR, 0.0),
(dhat_tool::ReadsBytes::SLUG_STR, 47_577_425.0),
(dhat_tool::WritesBytes::SLUG_STR, 37_733_810.0),
(iai_callgrind::TotalBytes::SLUG_STR, 26_294_939.0),
(iai_callgrind::TotalBlocks::SLUG_STR, 2_328_086.0),
(iai_callgrind::AtTGmaxBytes::SLUG_STR, 933_718.0),
(iai_callgrind::AtTGmaxBlocks::SLUG_STR, 18_344.0),
(iai_callgrind::AtTEndBytes::SLUG_STR, 0.0),
(iai_callgrind::AtTEndBlocks::SLUG_STR, 0.0),
(iai_callgrind::ReadsBytes::SLUG_STR, 47_577_425.0),
(iai_callgrind::WritesBytes::SLUG_STR, 37_733_810.0),
]);
}

Expand Down
74 changes: 33 additions & 41 deletions lib/bencher_adapter/src/results/adapter_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ impl AdapterResults {
inner: match measure {
AdapterMeasure::Latency(json_metric) => {
hmap! {
built_in::generic::Latency::name_id() => json_metric
built_in::default::Latency::name_id() => json_metric
}
},
AdapterMeasure::Throughput(json_metric) => {
hmap! {
built_in::generic::Throughput::name_id() => json_metric
built_in::default::Throughput::name_id() => json_metric
}
},
},
Expand Down Expand Up @@ -170,69 +170,61 @@ impl AdapterResults {
* Callgrind tool:
*/
IaiCallgrindMeasure::Instructions(json_metric) => (
built_in::iai_callgrind::callgrind_tool::Instructions::name_id(),
json_metric,
),
IaiCallgrindMeasure::L1Hits(json_metric) => (
built_in::iai_callgrind::callgrind_tool::L1Hits::name_id(),
json_metric,
),
IaiCallgrindMeasure::L2Hits(json_metric) => (
built_in::iai_callgrind::callgrind_tool::L2Hits::name_id(),
json_metric,
),
IaiCallgrindMeasure::RamHits(json_metric) => (
built_in::iai_callgrind::callgrind_tool::RamHits::name_id(),
built_in::iai_callgrind::Instructions::name_id(),
json_metric,
),
IaiCallgrindMeasure::L1Hits(json_metric) => {
(built_in::iai_callgrind::L1Hits::name_id(), json_metric)
},
IaiCallgrindMeasure::L2Hits(json_metric) => {
(built_in::iai_callgrind::L2Hits::name_id(), json_metric)
},
IaiCallgrindMeasure::RamHits(json_metric) => {
(built_in::iai_callgrind::RamHits::name_id(), json_metric)
},
IaiCallgrindMeasure::TotalReadWrite(json_metric) => (
built_in::iai_callgrind::callgrind_tool::TotalReadWrite::name_id(),
built_in::iai_callgrind::TotalReadWrite::name_id(),
json_metric,
),
IaiCallgrindMeasure::EstimatedCycles(json_metric) => (
built_in::iai_callgrind::callgrind_tool::EstimatedCycles::name_id(),
built_in::iai_callgrind::EstimatedCycles::name_id(),
json_metric,
),
IaiCallgrindMeasure::GlobalBusEvents(json_metric) => (
built_in::iai_callgrind::callgrind_tool::GlobalBusEvents::name_id(),
built_in::iai_callgrind::GlobalBusEvents::name_id(),
json_metric,
),

/*
* DHAT tool:
*/
IaiCallgrindMeasure::TotalBytes(json_metric) => (
built_in::iai_callgrind::dhat_tool::TotalBytes::name_id(),
json_metric,
),
IaiCallgrindMeasure::TotalBlocks(json_metric) => (
built_in::iai_callgrind::dhat_tool::TotalBlocks::name_id(),
json_metric,
),
IaiCallgrindMeasure::TotalBytes(json_metric) => {
(built_in::iai_callgrind::TotalBytes::name_id(), json_metric)
},
IaiCallgrindMeasure::TotalBlocks(json_metric) => {
(built_in::iai_callgrind::TotalBlocks::name_id(), json_metric)
},
IaiCallgrindMeasure::AtTGmaxBytes(json_metric) => (
built_in::iai_callgrind::dhat_tool::AtTGmaxBytes::name_id(),
built_in::iai_callgrind::AtTGmaxBytes::name_id(),
json_metric,
),
IaiCallgrindMeasure::AtTGmaxBlocks(json_metric) => (
built_in::iai_callgrind::dhat_tool::AtTGmaxBlocks::name_id(),
json_metric,
),
IaiCallgrindMeasure::AtTEndBytes(json_metric) => (
built_in::iai_callgrind::dhat_tool::AtTEndBytes::name_id(),
built_in::iai_callgrind::AtTGmaxBlocks::name_id(),
json_metric,
),
IaiCallgrindMeasure::AtTEndBytes(json_metric) => {
(built_in::iai_callgrind::AtTEndBytes::name_id(), json_metric)
},
IaiCallgrindMeasure::AtTEndBlocks(json_metric) => (
built_in::iai_callgrind::dhat_tool::AtTEndBlocks::name_id(),
json_metric,
),
IaiCallgrindMeasure::ReadsBytes(json_metric) => (
built_in::iai_callgrind::dhat_tool::ReadsBytes::name_id(),
json_metric,
),
IaiCallgrindMeasure::WritesBytes(json_metric) => (
built_in::iai_callgrind::dhat_tool::WritesBytes::name_id(),
built_in::iai_callgrind::AtTEndBlocks::name_id(),
json_metric,
),
IaiCallgrindMeasure::ReadsBytes(json_metric) => {
(built_in::iai_callgrind::ReadsBytes::name_id(), json_metric)
},
IaiCallgrindMeasure::WritesBytes(json_metric) => {
(built_in::iai_callgrind::WritesBytes::name_id(), json_metric)
},
};
metrics_value.inner.insert(resource_id, metric);
}
Expand Down
Loading

0 comments on commit 2797707

Please sign in to comment.