Skip to content
Myr

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

8 files+129 added−96 removed

modified:src/benchmark/executor.rs+4 added-17 removed
77 unmodified lines
7879 let measurement = execute_and_measure(command)80 .with_context(|| format!("Failed to run command '{command_name}'"))?;8182 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;8485 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 true
11 unmodified lines
106 };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}")113114 ),
247 unmodified lines
modified:src/benchmark/measurement.rs-4 removed
113 unmodified lines
114115 pub fn peak_memory_usage_mean(&self) -> Information {116 mean(self.measurements.iter().map(|m| m.peak_memory_usage))117 }118119 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 lines
378 let user_str = measurements.time_user_mean().format(time_unit);379 let system_str = measurements.time_system_mean().format(time_unit);380381 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 " ", // alignment
104 unmodified lines
modified:src/benchmark/scheduler.rs+2 added-2 removed
91 unmodified lines
92 console_writeln!(93 stdout,94 " {} ran",95 reference.result.command_with_unused_parameters().cyan()96 );96 )?;9798 for item in others {99 let stddev = if let Some(stddev) = item.relative_speed_stddev {100 format!(" ± {}", format!("{:.2}", stddev).green())
21 unmodified lines
122 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 lines
modified:src/export/mod.rs+1 added
16 unmodified lines
17use self::orgmode::OrgmodeExporter;1819use crate::benchmark::benchmark_result::BenchmarkResult;20use crate::options::SortOrder;21use crate::output::console_writeln;22use crate::quantity::TimeUnit;2324use anyhow::{Context, Result};25use clap::ArgMatches;
151 unmodified lines
modified:src/timer/unix_timer.rs+28 added-23 removed
35 unmodified lines
36 let pid = child.id() as i32;37 let mut status = 0;38 let mut rusage = MaybeUninit::zeroed();3940 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 }5042 if result < 0 {43 Err(io::Error::last_os_error())51 let rusage = unsafe { rusage.assume_init() };5253 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 };6247 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 };5657 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}7273pub struct CPUTimer {}74
15 unmodified lines
modified:Cargo.lock+89 added-43 removed
97 unmodified lines
98]99100[[package]]101name = "autocfg"102version = "1.4.0"102version = "1.5.1"103source = "registry+https://github.com/rust-lang/crates.io-index"104checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"104checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"105106[[package]]107name = "bitflags"108version = "2.6.0"108version = "2.13.2"109source = "registry+https://github.com/rust-lang/crates.io-index"110checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"110checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"111112[[package]]113name = "bitvec"114version = "1.0.1"115source = "registry+https://github.com/rust-lang/crates.io-index"116checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"117dependencies = [118 "funty",119 "radium",120 "tap",121 "wyz",122]123124[[package]]113name = "borsh"114version = "1.8.1"115source = "registry+https://github.com/rust-lang/crates.io-index"116checksum = "553c5d846a6ba5150c65e3b1b8ec073bcf1abc20f9b7220de384a4443ea4e20a"
96 unmodified lines
213[[package]]214name = "clap_lex"215version = "1.1.1"216source = "registry+https://github.com/rust-lang/crates.io-index"229checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"217checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486"218219[[package]]220name = "colorchoice"221version = "1.0.5"
106 unmodified lines
328 "num-traits",329]330331[[package]]344name = "funty"345version = "2.0.0"346source = "registry+https://github.com/rust-lang/crates.io-index"347checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"348349[[package]]332name = "getrandom"333version = "0.2.17"334source = "registry+https://github.com/rust-lang/crates.io-index"335checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
50 unmodified lines
386 "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]400401[[package]]402name = "indexmap"
213 unmodified lines
616checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"617618[[package]]619name = "rand"638version = "0.8.5"620version = "0.8.8"621source = "registry+https://github.com/rust-lang/crates.io-index"640checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"622checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c"623dependencies = [624 "libc",643 "rand_chacha",644 "rand_core",625 "rand_chacha 0.3.1",626 "rand_core 0.6.4",627]628629[[package]]630name = "rand"631version = "0.9.5"632source = "registry+https://github.com/rust-lang/crates.io-index"633checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41"634dependencies = [635 "rand_chacha 0.9.0",636 "rand_core 0.9.5",637]638639[[package]]640name = "rand"641version = "0.10.3"642source = "registry+https://github.com/rust-lang/crates.io-index"643checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"644dependencies = [645 "chacha20",646 "getrandom 0.4.3",647 "rand_core 0.10.1",648]649650[[package]]651name = "rand_chacha"652version = "0.3.1"653source = "registry+https://github.com/rust-lang/crates.io-index"654checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"655dependencies = [656 "ppv-lite86",654 "rand_core",657 "rand_core 0.6.4",658]659660[[package]]661name = "rand_chacha"662version = "0.9.0"663source = "registry+https://github.com/rust-lang/crates.io-index"664checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"665dependencies = [666 "ppv-lite86",667 "rand_core 0.9.5",668]669670[[package]]671name = "rand_core"672version = "0.6.4"673source = "registry+https://github.com/rust-lang/crates.io-index"674checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
1 unmodified line
676 "getrandom 0.2.17",677]678679[[package]]680name = "rand_core"681version = "0.9.5"682source = "registry+https://github.com/rust-lang/crates.io-index"683checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"684dependencies = [685 "getrandom 0.3.4",686]687688[[package]]689name = "rand_core"690version = "0.10.1"691source = "registry+https://github.com/rust-lang/crates.io-index"692checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"693694[[package]]695name = "regex"696version = "1.13.1"697source = "registry+https://github.com/rust-lang/crates.io-index"698checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
30 unmodified lines
729 "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 lines
817source = "registry+https://github.com/rust-lang/crates.io-index"818checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"819820[[package]]821name = "strip-ansi-escapes"822version = "0.2.1"823source = "registry+https://github.com/rust-lang/crates.io-index"824checksum = "2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025"825dependencies = [826 "vte",827]828829[[package]]830name = "strsim"831version = "0.11.1"832source = "registry+https://github.com/rust-lang/crates.io-index"833checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
90 unmodified lines
924 "winnow",925]926927[[package]]891name = "typenum"892version = "1.17.0"928name = "toml_parser"929version = "1.1.3+spec-1.1.0"930source = "registry+https://github.com/rust-lang/crates.io-index"894checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"895896[[package]]897name = "unicode-ident"898version = "1.0.13"899source = "registry+https://github.com/rust-lang/crates.io-index"931checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56"932dependencies = [933 "winnow",934]
16 unmodified lines
951source = "registry+https://github.com/rust-lang/crates.io-index"952checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"953954[[package]]955name = "unicode-width"956version = "0.2.2"957source = "registry+https://github.com/rust-lang/crates.io-index"958checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"959960[[package]]961name = "uom"962version = "0.36.0"963source = "registry+https://github.com/rust-lang/crates.io-index"964checksum = "ffd36e5350a65d112584053ee91843955826bf9e56ec0d1351214e01f6d7cd9c"
32 unmodified lines
997source = "registry+https://github.com/rust-lang/crates.io-index"998checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"9991000[[package]]964name = "windows-sys"965version = "0.48.0"1001name = "wasip2"1002version = "1.0.4+wasi-0.2.12"1003source = "registry+https://github.com/rust-lang/crates.io-index"967checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"1004checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"1005dependencies = [1006 "wit-bindgen",1007]10081009[[package]]1010name = "wasm-bindgen"1011version = "0.2.129"1012source = "registry+https://github.com/rust-lang/crates.io-index"1013checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"1014dependencies = [1015 "cfg-if",1016 "once_cell",1017 "rustversion",1018 "serde",
164 unmodified lines
modified:Cargo.toml+2 added-6 removed