From d8d41fc46029c205b0831d583485ae65a68d9b42 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Wed, 23 Apr 2025 23:09:32 -0400 Subject: [PATCH] remove cachegrind support --- README.md | 5 ----- examples/cachegrind.json | 4 ---- src/config.rs | 9 --------- src/main.rs | 40 ---------------------------------------- tests/examples.rs | 16 ---------------- 5 files changed, 74 deletions(-) delete mode 100644 examples/cachegrind.json diff --git a/README.md b/README.md index 271eff1..7834e43 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,6 @@ Create a JSON or YAML file with the following properties: * **`iterations`**: The number of times to run the the `run` test. The results for each iteration will be in an `iterations` array in the resultant JSON. The default is 1. -* **`cachegrind`**: If set to `true`, will run the test (after having already - run it normally) using cachegrind to add an instruction count to the results - JSON. Will only happen once, and be inserted into the top level JSON, - regardless of `iterations`. This requires that `valgrind` is installed on your - system. * **`instructions`**: If set to `true`, will take instruction counts from hardware counters if available, adding the result under the key `instructions`, for each iteration. This is only available on Linux with diff --git a/examples/cachegrind.json b/examples/cachegrind.json deleted file mode 100644 index 7ebb2ba..0000000 --- a/examples/cachegrind.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "run": "bash -c \"exit 0\"", - "cachegrind": true -} diff --git a/src/config.rs b/src/config.rs index 650fdc7..a9270be 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,7 +20,6 @@ pub(crate) struct Config { pub(crate) run: Vec, pub(crate) timeout: Option, pub(crate) env: HashMap, - pub(crate) cachegrind: bool, pub(crate) iterations: u64, pub(crate) instructions: bool, pub(crate) variants: Option>, @@ -70,7 +69,6 @@ lazy_static! { static ref SETUP_KEY: Value = "setup".into(); static ref TEARDOWN_KEY: Value = "teardown".into(); static ref TIMEOUT_KEY: Value = "timeout".into(); - static ref CACHEGRIND_KEY: Value = "cachegrind".into(); static ref ITERATIONS_KEY: Value = "iterations".into(); static ref INSTRUCTIONS_KEY: Value = "instructions".into(); } @@ -115,12 +113,6 @@ fn apply_config(config: &mut Config, config_val: &Value) -> Result<()> { ); } - if let Some(cachegrind_val) = config_val.get(&CACHEGRIND_KEY) { - config.cachegrind = cachegrind_val - .as_bool() - .ok_or_else(|| anyhow!("'cachegrind' must be a boolean"))?; - } - if let Some(iterations_val) = config_val.get(&ITERATIONS_KEY) { config.iterations = iterations_val .as_u64() @@ -150,7 +142,6 @@ pub(crate) fn get_config(filename: &str) -> Result { run: vec!["INIT".into()], timeout: None, env: HashMap::new(), - cachegrind: false, instructions: false, iterations: 1, variants: None, diff --git a/src/main.rs b/src/main.rs index 7a0d1d0..bfd2e4b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -190,46 +190,6 @@ async fn main_main() -> Result<()> { } metrics.insert("iterations".into(), MetricValue::Arr(iterations)); - if config.cachegrind && which("valgrind").is_ok() { - let command = "valgrind"; - let mut args = vec![ - "--tool=cachegrind".to_owned(), - "--trace-children=yes".to_owned(), - // Set some reasonable L1 and LL values. It is important that these - // values are consistent across runs, instead of the default. - "--I1=32768,8,64".to_owned(), - "--D1=32768,8,64".to_owned(), - "--LL=8388608,16,64".to_owned(), - ]; - args.append(&mut config.run.clone()); - run_setup(&config).await?; - let output = Command::new(command) - .args(args) - .envs(&config.env) - .output() - .await?; - run_teardown(&config).await?; - let stderr = String::from_utf8_lossy(&output.stderr); - - let lines = stderr.trim().lines().filter(|x| x.contains("I refs:")); - let mut instructions: f64 = 0.0; - for line in lines { - instructions += line - .trim() - .split_whitespace() - .last() - .expect("Bad cachegrind output: invalid instruction ref line") - .replace(",", "") - .parse::() - .expect("Bad cachegrind output: invalid number"); - } - if instructions <= 0.0 { - eprintln!("Bad cachegrind output: no instructions parsed"); - exit(1); - } - metrics.insert("instructions".into(), instructions.into()); - } - if let Ok(hash) = env::var("GIT_COMMIT_HASH") { metrics.insert("version".into(), hash.into()); } diff --git a/tests/examples.rs b/tests/examples.rs index 89d6507..824917c 100644 --- a/tests/examples.rs +++ b/tests/examples.rs @@ -178,22 +178,6 @@ fn stdio() { .stdout(predicate::str::contains("setup was run").not()); } -#[test] -#[serial] -fn cachegrind() { - if std::env::consts::OS == "linux" { - run!("./examples/cachegrind.json") - .assert() - .success() - .stdout(predicate::str::contains("\"instructions\":")); - } else { - run!("./examples/cachegrind.json") - .assert() - .success() - .stdout(predicate::str::contains("\"instructions\":").not()); - } -} - #[test] #[serial] fn iterations() {