mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-31 19:05:00 +07:00
parent
f107708de3
commit
74ac5ece6a
2 changed files with 32 additions and 5 deletions
|
|
@ -388,7 +388,6 @@ impl std::fmt::Display for Output {
|
||||||
)?,
|
)?,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writeln!(f)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@
|
||||||
//! being created (unless no tests were run). These results can be automatically
|
//! being created (unless no tests were run). These results can be automatically
|
||||||
//! compared. To do so, run `cargo perf-compare new-ident old-ident`.
|
//! compared. To do so, run `cargo perf-compare new-ident old-ident`.
|
||||||
//!
|
//!
|
||||||
|
//! To save the markdown output to a file instead, run `cargo perf-compare --save=$FILE
|
||||||
|
//! new-ident old-ident`.
|
||||||
|
//!
|
||||||
//! NB: All files matching `.perf-runs/ident.*.json` will be considered when
|
//! NB: All files matching `.perf-runs/ident.*.json` will be considered when
|
||||||
//! doing this comparison, so ensure there aren't leftover files in your `.perf-runs`
|
//! doing this comparison, so ensure there aren't leftover files in your `.perf-runs`
|
||||||
//! directory that might match that!
|
//! directory that might match that!
|
||||||
|
|
@ -91,7 +94,7 @@ impl OutputKind<'_> {
|
||||||
/// Logs the output of a run as per the `OutputKind`.
|
/// Logs the output of a run as per the `OutputKind`.
|
||||||
fn log(&self, output: &Output, t_bin: &str) {
|
fn log(&self, output: &Output, t_bin: &str) {
|
||||||
match self {
|
match self {
|
||||||
OutputKind::Markdown => print!("{output}"),
|
OutputKind::Markdown => println!("{output}"),
|
||||||
OutputKind::Json(ident) => {
|
OutputKind::Json(ident) => {
|
||||||
// We're going to be in tooling/perf/$whatever.
|
// We're going to be in tooling/perf/$whatever.
|
||||||
let wspace_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap())
|
let wspace_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap())
|
||||||
|
|
@ -215,8 +218,23 @@ fn parse_mdata(t_bin: &str, mdata_fn: &str) -> Result<TestMdata, FailKind> {
|
||||||
|
|
||||||
/// Compares the perf results of two profiles as per the arguments passed in.
|
/// Compares the perf results of two profiles as per the arguments passed in.
|
||||||
fn compare_profiles(args: &[String]) {
|
fn compare_profiles(args: &[String]) {
|
||||||
let ident_new = args.first().expect("FATAL: missing identifier for new run");
|
let mut save_to = None;
|
||||||
let ident_old = args.get(1).expect("FATAL: missing identifier for old run");
|
let mut ident_idx = 0;
|
||||||
|
args.first().inspect(|a| {
|
||||||
|
if a.starts_with("--save") {
|
||||||
|
save_to = Some(
|
||||||
|
a.strip_prefix("--save=")
|
||||||
|
.expect("FATAL: save param formatted incorrectly"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
ident_idx = 1;
|
||||||
|
});
|
||||||
|
let ident_new = args
|
||||||
|
.get(ident_idx)
|
||||||
|
.expect("FATAL: missing identifier for new run");
|
||||||
|
let ident_old = args
|
||||||
|
.get(ident_idx + 1)
|
||||||
|
.expect("FATAL: missing identifier for old run");
|
||||||
let wspace_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
let wspace_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
let runs_dir = PathBuf::from(&wspace_dir)
|
let runs_dir = PathBuf::from(&wspace_dir)
|
||||||
.join("..")
|
.join("..")
|
||||||
|
|
@ -260,7 +278,17 @@ fn compare_profiles(args: &[String]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = outputs_new.compare_perf(outputs_old);
|
let res = outputs_new.compare_perf(outputs_old);
|
||||||
println!("{res}");
|
if let Some(filename) = save_to {
|
||||||
|
let mut file = std::fs::OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.write(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(filename)
|
||||||
|
.expect("FATAL: couldn't save run results to file");
|
||||||
|
file.write_all(format!("{res}").as_bytes()).unwrap();
|
||||||
|
} else {
|
||||||
|
println!("{res}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs a test binary, filtering out tests which aren't marked for perf triage
|
/// Runs a test binary, filtering out tests which aren't marked for perf triage
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue