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
Provenance
- Commit
038f369- Tree
823abcb- Author
David Peter <mail@david-peter.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
0705d6c
3 files changed+24 added−18 removed
modified:src/benchmark/scheduler.rs+7 added-8 removed
50 unmodified lines51 .push(Benchmark::new(number, cmd, self.options, &*executor).run()?);52 53 // 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 }57 58 Ok(())59 }93 unmodified lines153 }154 }155 156 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 }160 161 #[cfg(test)]8 unmodified lines170 171 assert_eq!(options.executor_kind, ExecutorKind::Mock(None));172 173 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+ )?;179 180 options.validate_against_command_list(&commands)?;181 182 let mut scheduler = Scheduler::new(&commands, &options, &export_manager);46 unmodified linesmodified:src/export/mod.rs+12 added-9 removed
62 unmodified lines63 target: ExportTarget,64 }65 66 /// Handles the management of multiple file exporters.67-#[derive(Default)]67 pub struct ExportManager {68 exporters: Vec<ExporterWithTarget>,69 time_unit: Option<Unit>,70+ sort_order: SortOrder,71 }72 73 impl 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 lines128 /// 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+ };138 139 match e.target {140 ExportTarget::File(ref filename) => {141 if intermediate {21 unmodified linesmodified:src/main.rs+5 added-1 removed
32 unmodified lines33 34 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+ )?;42 43 options.validate_against_command_list(&commands)?;44 45 let mut scheduler = Scheduler::new(&commands, &options, &export_manager);16 unmodified lines