Skip to content
Myr

SortOrder field

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 0705d6c · Browse files · 3 files+24 added−18 removed
This commit

State

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

Diff stats

3 files+24 added−18 removed

  • other:+24 added−18 removed

3 files+24 added−18 removed

modified:src/benchmark/scheduler.rs+7 added-8 removed
50 unmodified lines
51 .push(Benchmark::new(number, cmd, self.options, &*executor).run()?);5253 // We export results after each individual benchmark, because54 // we would risk losing them if a later benchmark fails.55 self.export_manager.write_results(56 &self.results,57 self.options.sort_order_exports,58 true,59 )?;55 self.export_manager.write_results(&self.results, true)?;56 }5758 Ok(())59 }
93 unmodified lines
153 }154 }155156 pub fn final_export(&self) -> Result<()> {161 self.export_manager162 .write_results(&self.results, self.options.sort_order_exports, false)157 self.export_manager.write_results(&self.results, false)158 }159}160161#[cfg(test)]
8 unmodified lines
170171 assert_eq!(options.executor_kind, ExecutorKind::Mock(None));172173 let commands = Commands::from_cli_arguments(&cli_arguments)?;179 let export_manager = ExportManager::from_cli_arguments(&cli_arguments, options.time_unit)?;174 let export_manager = ExportManager::from_cli_arguments(175 &cli_arguments,176 options.time_unit,177 options.sort_order_exports,178 )?;179180 options.validate_against_command_list(&commands)?;181182 let mut scheduler = Scheduler::new(&commands, &options, &export_manager);
46 unmodified lines
modified:src/export/mod.rs+12 added-9 removed
62 unmodified lines
63 target: ExportTarget,64}6566/// Handles the management of multiple file exporters.67#[derive(Default)]67pub struct ExportManager {68 exporters: Vec<ExporterWithTarget>,69 time_unit: Option<Unit>,70 sort_order: SortOrder,71}7273impl ExportManager {74 /// Build the ExportManager that will export the results specified75 /// in the given ArgMatches76 pub fn from_cli_arguments(matches: &ArgMatches, time_unit: Option<Unit>) -> Result<Self> {76 pub fn from_cli_arguments(77 matches: &ArgMatches,78 time_unit: Option<Unit>,79 sort_order: SortOrder,80 ) -> Result<Self> {81 let mut export_manager = Self {82 exporters: vec![],83 time_unit,84 sort_order,85 };86 {87 let mut add_exporter = |flag, exporttype| -> Result<()> {88 if let Some(filename) = matches.get_one::<String>(flag) {
39 unmodified lines
128 /// is the final call after all benchmarks have been finished. In the former case,129 /// results are written to all file targets (to always have them up to date, even130 /// if a benchmark fails). In the latter case, we only print to stdout targets (in131 /// order not to clutter the output of hyperfine with intermediate results).127 pub fn write_results(128 &self,129 results: &[BenchmarkResult],130 sort_order: SortOrder,131 intermediate: bool,132 ) -> Result<()> {132 pub fn write_results(&self, results: &[BenchmarkResult], intermediate: bool) -> Result<()> {133 for e in &self.exporters {134 let content = || e.exporter.serialize(results, self.time_unit, sort_order);134 let content = || {135 e.exporter136 .serialize(results, self.time_unit, self.sort_order)137 };138139 match e.target {140 ExportTarget::File(ref filename) => {141 if intermediate {
21 unmodified lines
modified:src/main.rs+5 added-1 removed
32 unmodified lines
3334 let cli_arguments = get_cli_arguments(env::args_os());35 let mut options = Options::from_cli_arguments(&cli_arguments)?;36 let commands = Commands::from_cli_arguments(&cli_arguments)?;37 let export_manager = ExportManager::from_cli_arguments(&cli_arguments, options.time_unit)?;37 let export_manager = ExportManager::from_cli_arguments(38 &cli_arguments,39 options.time_unit,40 options.sort_order_exports,41 )?;4243 options.validate_against_command_list(&commands)?;4445 let mut scheduler = Scheduler::new(&commands, &options, &export_manager);
16 unmodified lines