SortOrder field

This commit is contained in:
David Peter authored and David Peter committed 2024-12-29 14:07:21 +01:00
1 parent 0705d6c7d0
commit 038f369420
3 files changed
+24 -18

No files matched your search

+12 -9
View File
@@ -64,19 +64,24 @@ struct ExporterWithTarget {
}
/// Handles the management of multiple file exporters.
#[derive(Default)]
pub struct ExportManager {
exporters: Vec<ExporterWithTarget>,
time_unit: Option<Unit>,
sort_order: SortOrder,
}
impl ExportManager {
/// Build the ExportManager that will export the results specified
/// in the given ArgMatches
pub fn from_cli_arguments(matches: &ArgMatches, time_unit: Option<Unit>) -> Result<Self> {
pub fn from_cli_arguments(
matches: &ArgMatches,
time_unit: Option<Unit>,
sort_order: SortOrder,
) -> Result<Self> {
let mut export_manager = Self {
exporters: vec![],
time_unit,
sort_order,
};
{
let mut add_exporter = |flag, exporttype| -> Result<()> {
@@ -124,14 +129,12 @@ impl ExportManager {
/// results are written to all file targets (to always have them up to date, even
/// if a benchmark fails). In the latter case, we only print to stdout targets (in
/// order not to clutter the output of hyperfine with intermediate results).
pub fn write_results(
&self,
results: &[BenchmarkResult],
sort_order: SortOrder,
intermediate: bool,
) -> Result<()> {
pub fn write_results(&self, results: &[BenchmarkResult], intermediate: bool) -> Result<()> {
for e in &self.exporters {
let content = || e.exporter.serialize(results, self.time_unit, sort_order);
let content = || {
e.exporter
.serialize(results, self.time_unit, self.sort_order)
};
match e.target {
ExportTarget::File(ref filename) => {