Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions crates/cargo-codspeed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ anstyle = "1.0.8"
serde = { workspace = true }
serde_json = { workspace = true }
codspeed = { path = "../codspeed", version = "=2.10.1" }
glob = "0.3.2"
statrs = "0.18.0"

[dev-dependencies]
assert_cmd = "2.0.15"
Expand Down
1 change: 0 additions & 1 deletion crates/cargo-codspeed/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ mod helpers;
mod measurement_mode;
mod prelude;
mod run;
mod walltime_results;

use crate::prelude::*;
use std::{env::args_os, process::exit};
Expand Down
34 changes: 5 additions & 29 deletions crates/cargo-codspeed/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ use crate::{
helpers::get_codspeed_target_dir,
measurement_mode::MeasurementMode,
prelude::*,
walltime_results::{WalltimeBenchmark, WalltimeResults},
};
use anyhow::Context;
use cargo_metadata::{Metadata, Package};
use codspeed::walltime::get_raw_result_dir_from_workspace_root;
use glob::glob;
use codspeed::walltime_results::WalltimeResults;
use std::{
io::{self, Write},
os::unix::process::ExitStatusExt,
Expand Down Expand Up @@ -103,7 +101,7 @@ pub fn run_benches(
let codspeed_target_dir = get_codspeed_target_dir(metadata, measurement_mode);
let workspace_root = metadata.workspace_root.as_std_path();
if measurement_mode == MeasurementMode::Walltime {
clear_raw_walltime_data(workspace_root)?;
WalltimeResults::clear(workspace_root)?;
}
let benches = filters.benches_to_run(codspeed_target_dir, metadata)?;
if benches.is_empty() {
Expand Down Expand Up @@ -181,35 +179,14 @@ pub fn run_benches(
Ok(())
}

fn clear_raw_walltime_data(workspace_root: &Path) -> Result<()> {
let raw_results_dir = get_raw_result_dir_from_workspace_root(workspace_root);
std::fs::remove_dir_all(&raw_results_dir).ok(); // ignore errors when the directory does not exist
std::fs::create_dir_all(&raw_results_dir).context("Failed to create raw_results directory")?;
Ok(())
}

fn aggregate_raw_walltime_data(workspace_root: &Path) -> Result<()> {
// retrieve data from `{workspace_root}/target/codspeed/raw_results/{scope}/*.json
let walltime_benchmarks = glob(&format!(
"{}/**/*.json",
get_raw_result_dir_from_workspace_root(workspace_root)
.to_str()
.unwrap(),
))?
.map(|sample| {
let sample = sample?;
let raw_walltime_data: codspeed::walltime::RawWallTimeData =
serde_json::from_reader(std::fs::File::open(&sample)?)?;
Ok(WalltimeBenchmark::from(raw_walltime_data))
})
.collect::<Result<Vec<_>>>()?;

if walltime_benchmarks.is_empty() {
let results = WalltimeResults::collect_walltime_results(workspace_root)?;
if results.benchmarks().is_empty() {
eprintln!("No walltime benchmarks found");
return Ok(());
}

for bench in &walltime_benchmarks {
for bench in results.benchmarks() {
if bench.is_invalid() {
eprintln!(
"Warning: Benchmark {} was possibly optimized away",
Expand All @@ -224,7 +201,6 @@ fn aggregate_raw_walltime_data(workspace_root: &Path) -> Result<()> {
.join("results");
std::fs::create_dir_all(&results_folder).context("Failed to create results folder")?;

let results = WalltimeResults::from_benchmarks(walltime_benchmarks);
let results_path = results_folder.join(format!("{}.json", std::process::id()));
let mut results_file =
std::fs::File::create(&results_path).context("Failed to create results file")?;
Expand Down
222 changes: 0 additions & 222 deletions crates/cargo-codspeed/src/walltime_results.rs

This file was deleted.

2 changes: 2 additions & 0 deletions crates/codspeed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ keywords = ["codspeed", "benchmark"]
anyhow = { workspace = true }
bincode = "1.3.3"
colored = "2.0.0"
glob = "0.3.2"
libc = "^0.2"
nix = { version = "0.29.0", features = ["fs"] }
serde = { workspace = true }
serde_json = { workspace = true }
statrs = "0.18.0"
uuid = { version = "1.12.1", features = ["v4"] }

[[bench]]
Expand Down
2 changes: 1 addition & 1 deletion crates/codspeed/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ mod measurement;
mod request;
mod shared;
pub mod utils;
pub mod walltime;
pub mod walltime_results;
Loading
Loading