Add new --sort option

This adds a new `--sort` option to choose the way in which the results
in the speed comparison and the markup exports are ordered.

closes #614
closes #601
This commit is contained in:
David Peter authored and David Peter committed 2023-06-03 21:34:36 +02:00
1 parent 2393de0c36
commit ac617c8714
12 files changed
+285 -89

No files matched your search

+8 -2
View File
@@ -1,5 +1,6 @@
use crate::benchmark::relative_speed::BenchmarkResultWithRelativeSpeed;
use crate::benchmark::{benchmark_result::BenchmarkResult, relative_speed};
use crate::options::SortOrder;
use crate::output::format::format_duration_value;
use crate::util::units::Unit;
@@ -105,9 +106,14 @@ fn determine_unit_from_results(results: &[BenchmarkResult]) -> Unit {
}
impl<T: MarkupExporter> Exporter for T {
fn serialize(&self, results: &[BenchmarkResult], unit: Option<Unit>) -> Result<Vec<u8>> {
fn serialize(
&self,
results: &[BenchmarkResult],
unit: Option<Unit>,
sort_order: SortOrder,
) -> Result<Vec<u8>> {
let unit = unit.unwrap_or_else(|| determine_unit_from_results(results));
let entries = relative_speed::compute(results);
let entries = relative_speed::compute(results, sort_order);
let table = self.table_results(&entries, unit);
Ok(table.as_bytes().to_vec())