Skip to content
Myr

Basic scheduler test

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 0d2e3a4 · Browse files · 2 files+66 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+66 added−0 removed

  • other:+66 added−0 removed

2 files+66 added−0 removed

modified:src/benchmark/scheduler.rs+65 added
160 unmodified lines
161 self.export_manager162 .write_results(&self.results, self.options.sort_order_exports, false)163 }164}165166#[cfg(test)]167fn generate_results(args: &[&'static str]) -> Result<Vec<BenchmarkResult>> {168 use crate::cli::get_cli_arguments;169170 let args = ["hyperfine", "--debug-mode", "--style=none"]171 .iter()172 .chain(args.into_iter());173 let cli_arguments = get_cli_arguments(args);174 let mut options = Options::from_cli_arguments(&cli_arguments)?;175176 assert_eq!(options.executor_kind, ExecutorKind::Mock(None));177178 let commands = Commands::from_cli_arguments(&cli_arguments)?;179 let export_manager = ExportManager::from_cli_arguments(&cli_arguments, options.time_unit)?;180181 options.validate_against_command_list(&commands)?;182183 let mut scheduler = Scheduler::new(&commands, &options, &export_manager);184185 scheduler.run_benchmarks()?;186 Ok(scheduler.results)187}188189#[test]190fn scheduler_basic() -> Result<()> {191 insta::assert_yaml_snapshot!(generate_results(&["--runs=2", "sleep 0.123", "sleep 0.456"])?, @r#"192 - command: sleep 0.123193 mean: 0.123194 stddev: 0195 median: 0.123196 user: 0197 system: 0198 min: 0.123199 max: 0.123200 times:201 - 0.123202 - 0.123203 memory_usage_byte:204 - 0205 - 0206 exit_codes:207 - 0208 - 0209 - command: sleep 0.456210 mean: 0.456211 stddev: 0212 median: 0.456213 user: 0214 system: 0215 min: 0.456216 max: 0.456217 times:218 - 0.456219 - 0.456220 memory_usage_byte:221 - 0222 - 0223 exit_codes:224 - 0225 - 0226 "#);227228 Ok(())229}
modified:src/options.rs+1 added
176 unmodified lines
177 Ok(streams)178 }179}180181#[derive(Debug, PartialEq)]182pub enum ExecutorKind {183 Raw,184 Shell(Shell),185 Mock(Option<String>),
340 unmodified lines