Resolve overlap with merged measurement refactors and current master
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Peter · committed by David Peter · parent 7a80feb · Browse files · 8 files·+129 added−96 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+129 added−96 removed
- other:+129 added−96 removed
Provenance
- Commit
cf38199- Tree
0016377- Author
David Peter <sharkdp@users.noreply.github.com>- Committer
David Peter <mail@david-peter.de>- Parent
7a80feb
8 files changed+129 added−96 removed
modified:src/benchmark/executor.rs+4 added-17 removed
77 unmodified lines78 79 let measurement = execute_and_measure(command)80 .with_context(|| format!("Failed to run command '{command_name}'"))?;81 82- if command_failure_action == CmdFailureAction::RaiseError && !measurement.exit_status.success()83- {84- let when = match iteration {85- BenchmarkIteration::NonBenchmarkRun => "a non-benchmark run".to_string(),86- BenchmarkIteration::Warmup(0) => "the first warmup run".to_string(),87- BenchmarkIteration::Warmup(i) => format!("warmup iteration {i}"),88- BenchmarkIteration::Benchmark(0) => "the first benchmark run".to_string(),89- BenchmarkIteration::Benchmark(i) => format!("benchmark iteration {i}"),90- };91- bail!(92- "{cause} in {when}. Use the '-i'/'--ignore-failure' option if you want to ignore this. \93- Alternatively, use the '--show-output' option to debug what went wrong.",94- cause=measurement.exit_status.code().map_or(95- "The process has been terminated by a signal".into(),96- |c| format!("Command terminated with non-zero exit code {c}")82+ if !measurement.exit_status.success() {83+ use crate::util::exit_code::extract_exit_code;84 85 let should_fail = match command_failure_action {86 CmdFailureAction::RaiseError => true,87 CmdFailureAction::IgnoreAllFailures => false,88 CmdFailureAction::IgnoreSpecificFailures(ref codes) => {89 // Only fail if the exit code is not in the list of codes to ignore103- if let Some(exit_code) = extract_exit_code(result.exit_status) {90+ if let Some(exit_code) = extract_exit_code(measurement.exit_status) {91 !codes.contains(&exit_code)92 } else {93 // If we can't extract an exit code, treat it as a failure94 true11 unmodified lines106 };107 bail!(108 "{cause} in {when}. Use the '-i'/'--ignore-failure' option if you want to ignore this. \109 Alternatively, use the '--show-output' option to debug what went wrong.",123- cause=result.exit_status.code().map_or(110+ cause=measurement.exit_status.code().map_or(111 "The process has been terminated by a signal".into(),112 |c| format!("Command terminated with non-zero exit code {c}")113 114 ),247 unmodified linesmodified:src/benchmark/measurement.rs-4 removed
113 unmodified lines114 115 pub fn peak_memory_usage_mean(&self) -> Information {116 mean(self.measurements.iter().map(|m| m.peak_memory_usage))117 }118-119- pub fn peak_memory_usage_mean(&self) -> Information {120- mean(self.measurements.iter().map(|m| m.peak_memory_usage))121- }118 }modified:src/benchmark/mod.rs+3 added-1 removed
377 unmodified lines378 let user_str = measurements.time_user_mean().format(time_unit);379 let system_str = measurements.time_system_mean().format(time_unit);380 381 if self.options.output_style != OutputStyleOption::Disabled {382+ let mut stdout = io::stdout().lock();383 if measurements.len() == 1 {383- println!(384+ console_writeln!(385+ stdout,386 " Time ({} ≡): {:>8} {:>8} [User: {}, System: {}]",387 "abs".green().bold(),388 mean_str.green().bold(),389 " ", // alignment104 unmodified linesmodified:src/benchmark/scheduler.rs+2 added-2 removed
91 unmodified lines92 console_writeln!(93 stdout,94 " {} ran",95 reference.result.command_with_unused_parameters().cyan()96- );96+ )?;97 98 for item in others {99 let stddev = if let Some(stddev) = item.relative_speed_stddev {100 format!(" ± {}", format!("{:.2}", stddev).green())21 unmodified lines122 stdout,123 "{} {}",124 comparator,125 &item.result.command_with_unused_parameters().magenta()126- );126+ )?;127 }128 }129 SortOrder::Command => {130 console_writeln!(stdout, "{}", "Relative speed comparison".bold())?;136 unmodified linesmodified:src/export/mod.rs+1 added
16 unmodified lines17 use self::orgmode::OrgmodeExporter;18 19 use crate::benchmark::benchmark_result::BenchmarkResult;20 use crate::options::SortOrder;21+use crate::output::console_writeln;22 use crate::quantity::TimeUnit;23 24 use anyhow::{Context, Result};25 use clap::ArgMatches;151 unmodified linesmodified:src/timer/unix_timer.rs+28 added-23 removed
35 unmodified lines36 let pid = child.id() as i32;37 let mut status = 0;38 let mut rusage = MaybeUninit::zeroed();39 40+ loop {40- let result = unsafe { libc::wait4(pid, &mut status, 0, rusage.as_mut_ptr()) };41+ let result = unsafe { libc::wait4(pid, &mut status, 0, rusage.as_mut_ptr()) };42+ if result >= 0 {43+ break;44+ }45+ let error = io::Error::last_os_error();46+ if error.kind() != io::ErrorKind::Interrupted {47+ return Err(error);48+ }49+ }50 42- if result < 0 {43- Err(io::Error::last_os_error())51+ let rusage = unsafe { rusage.assume_init() };52+53+ let memory_usage_byte = if cfg!(target_os = "macos") || cfg!(target_os = "ios") {54+ // Linux and *BSD return the value in KibiBytes, Darwin flavors in bytes55+ // A f64 can represent integers up to 2^53 exactly, so we can represent56+ // all values up to 2^53 bytes = 8 PiB exactly. Beyond that, our precision57+ // is larger than 1 byte, but that's considered acceptable.58+ Information::new::<byte>(rusage.ru_maxrss as f64)59 } else {45- let rusage = unsafe { rusage.assume_init() };60+ Information::new::<kibibyte>(rusage.ru_maxrss as f64)61+ };62 47- let memory_usage_byte = if cfg!(target_os = "macos") || cfg!(target_os = "ios") {48- // Linux and *BSD return the value in KibiBytes, Darwin flavors in bytes49- // A f64 can represent integers up to 2^53 exactly, so we can represent50- // all values up to 2^53 bytes = 8 PiB exactly. Beyond that, our precision51- // is larger than 1 byte, but that's considered acceptable.52- Information::new::<byte>(rusage.ru_maxrss as f64)53- } else {54- Information::new::<kibibyte>(rusage.ru_maxrss as f64)55- };56-57- Ok((58- ExitStatus::from_raw(status),59- ResourceUsage {60- time_user: convert_timeval(rusage.ru_utime),61- time_system: convert_timeval(rusage.ru_stime),62- memory_usage: memory_usage_byte.into(),63- },64- ))63+ Ok((64+ ExitStatus::from_raw(status),65+ ResourceUsage {66+ time_user: convert_timeval(rusage.ru_utime),67+ time_system: convert_timeval(rusage.ru_stime),68+ memory_usage: memory_usage_byte.into(),69+ },70+ ))65- }71 }72 73 pub struct CPUTimer {}74 15 unmodified linesmodified:Cargo.lock+89 added-43 removed
97 unmodified lines98 ]99 100 [[package]]101 name = "autocfg"102-version = "1.4.0"102+version = "1.5.1"103 source = "registry+https://github.com/rust-lang/crates.io-index"104-checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"104+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"105 106 [[package]]107 name = "bitflags"108-version = "2.6.0"108+version = "2.13.2"109 source = "registry+https://github.com/rust-lang/crates.io-index"110-checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"110+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"111 112 [[package]]113-name = "bitvec"114-version = "1.0.1"115-source = "registry+https://github.com/rust-lang/crates.io-index"116-checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"117-dependencies = [118- "funty",119- "radium",120- "tap",121- "wyz",122-]123-124-[[package]]113 name = "borsh"114 version = "1.8.1"115 source = "registry+https://github.com/rust-lang/crates.io-index"116 checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a"96 unmodified lines213 [[package]]214 name = "clap_lex"215 version = "1.1.1"216 source = "registry+https://github.com/rust-lang/crates.io-index"229-checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"217+checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"218 219 [[package]]220 name = "colorchoice"221 version = "1.0.5"106 unmodified lines328 "num-traits",329 ]330 331 [[package]]344-name = "funty"345-version = "2.0.0"346-source = "registry+https://github.com/rust-lang/crates.io-index"347-checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"348-349-[[package]]332 name = "getrandom"333 version = "0.2.17"334 source = "registry+https://github.com/rust-lang/crates.io-index"335 checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"50 unmodified lines386 "libc",387 "nix",388 "once_cell",389 "predicates",408- "rand",390+ "rand 0.10.3",391 "rust_decimal",392 "serde",393 "serde_json",394 "shell-words",395 "tempfile",396 "thiserror",397 "uom",416- "windows-sys 0.59.0",398+ "windows-sys 0.61.2",399 ]400 401 [[package]]402 name = "indexmap"213 unmodified lines616 checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"617 618 [[package]]619 name = "rand"638-version = "0.8.5"620+version = "0.8.8"621 source = "registry+https://github.com/rust-lang/crates.io-index"640-checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"622+checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c"623 dependencies = [624 "libc",643- "rand_chacha",644- "rand_core",625+ "rand_chacha 0.3.1",626+ "rand_core 0.6.4",627 ]628 629 [[package]]630+name = "rand"631+version = "0.9.5"632+source = "registry+https://github.com/rust-lang/crates.io-index"633+checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41"634+dependencies = [635+ "rand_chacha 0.9.0",636+ "rand_core 0.9.5",637+]638+639+[[package]]640+name = "rand"641+version = "0.10.3"642+source = "registry+https://github.com/rust-lang/crates.io-index"643+checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"644+dependencies = [645+ "chacha20",646+ "getrandom 0.4.3",647+ "rand_core 0.10.1",648+]649+650+[[package]]651 name = "rand_chacha"652 version = "0.3.1"653 source = "registry+https://github.com/rust-lang/crates.io-index"654 checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"655 dependencies = [656 "ppv-lite86",654- "rand_core",657+ "rand_core 0.6.4",658 ]659 660 [[package]]661+name = "rand_chacha"662+version = "0.9.0"663+source = "registry+https://github.com/rust-lang/crates.io-index"664+checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"665+dependencies = [666+ "ppv-lite86",667+ "rand_core 0.9.5",668+]669+670+[[package]]671 name = "rand_core"672 version = "0.6.4"673 source = "registry+https://github.com/rust-lang/crates.io-index"674 checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"1 unmodified line676 "getrandom 0.2.17",677 ]678 679 [[package]]680+name = "rand_core"681+version = "0.9.5"682+source = "registry+https://github.com/rust-lang/crates.io-index"683+checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"684+dependencies = [685+ "getrandom 0.3.4",686+]687+688+[[package]]689+name = "rand_core"690+version = "0.10.1"691+source = "registry+https://github.com/rust-lang/crates.io-index"692+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"693+694+[[package]]695 name = "regex"696 version = "1.13.1"697 source = "registry+https://github.com/rust-lang/crates.io-index"698 checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"30 unmodified lines729 "arrayvec",730 "borsh",731 "bytes",732 "num-traits",705- "rand",706- "rkyv",733+ "rand 0.8.8",734+ "rand 0.9.5",735 "serde",736 "serde_json",737 "wasm-bindgen",738 ]78 unmodified lines817 source = "registry+https://github.com/rust-lang/crates.io-index"818 checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"819 820 [[package]]821+name = "strip-ansi-escapes"822+version = "0.2.1"823+source = "registry+https://github.com/rust-lang/crates.io-index"824+checksum = "2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025"825+dependencies = [826+ "vte",827+]828+829+[[package]]830 name = "strsim"831 version = "0.11.1"832 source = "registry+https://github.com/rust-lang/crates.io-index"833 checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"90 unmodified lines924 "winnow",925 ]926 927 [[package]]891-name = "typenum"892-version = "1.17.0"928+name = "toml_parser"929+version = "1.1.3+spec-1.1.0"930 source = "registry+https://github.com/rust-lang/crates.io-index"894-checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"895-896-[[package]]897-name = "unicode-ident"898-version = "1.0.13"899-source = "registry+https://github.com/rust-lang/crates.io-index"931 checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56"932 dependencies = [933 "winnow",934 ]16 unmodified lines951 source = "registry+https://github.com/rust-lang/crates.io-index"952 checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"953 954 [[package]]955+name = "unicode-width"956+version = "0.2.2"957+source = "registry+https://github.com/rust-lang/crates.io-index"958+checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"959+960+[[package]]961 name = "uom"962 version = "0.36.0"963 source = "registry+https://github.com/rust-lang/crates.io-index"964 checksum = "ffd36e5350a65d112584053ee91843955826bf9e56ec0d1351214e01f6d7cd9c"32 unmodified lines997 source = "registry+https://github.com/rust-lang/crates.io-index"998 checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"999 1000 [[package]]964-name = "windows-sys"965-version = "0.48.0"1001+name = "wasip2"1002+version = "1.0.4+wasi-0.2.12"1003 source = "registry+https://github.com/rust-lang/crates.io-index"967-checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"1004+checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"1005 dependencies = [1006+ "wit-bindgen",1007+]1008+1009+[[package]]1010+name = "wasm-bindgen"1011+version = "0.2.129"1012+source = "registry+https://github.com/rust-lang/crates.io-index"1013+checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"1014+dependencies = [1015 "cfg-if",1016 "once_cell",1017 "rustversion",1018 "serde",164 unmodified linesmodified:Cargo.toml+2 added-6 removed
18 unmodified lines192021222323242526272829303132333435313233343548 unmodified lines18 unmodified lines[dependencies]colored = "3.1"# Newer versions regress ETA estimates: https://github.com/console-rs/indicatif/issues/580indicatif = "=0.17.4"csv = "1.3"csv = "1.4"serde = { version = "1.0", features = ["derive"] }serde_json = "1.0"rust_decimal = "1.43"rand = "0.10"shell-words = "1.1"thiserror = "2.0"anyhow = "1.0"uom = { version = "0.36.0", default-features = false, features = [ "std", "si", "f64",] }uom = { version = "0.36.0", default-features = false, features = ["std", "si", "f64"] }
[target.'cfg(not(windows))'.dependencies]libc = "0.2"
48 unmodified lines