diff --git a/src/hyperfine/export/asciidoc.rs b/src/hyperfine/export/asciidoc.rs index ea53179..4d947eb 100644 --- a/src/hyperfine/export/asciidoc.rs +++ b/src/hyperfine/export/asciidoc.rs @@ -10,7 +10,7 @@ use std::io::Result; pub struct AsciidocExporter {} impl Exporter for AsciidocExporter { - fn serialize(&self, results: &Vec, unit: Option) -> Result> { + fn serialize(&self, results: &[BenchmarkResult], unit: Option) -> Result> { let unit = if let Some(unit) = unit { // Use the given unit for all entries. unit diff --git a/src/hyperfine/export/csv.rs b/src/hyperfine/export/csv.rs index 8b611e6..1612952 100644 --- a/src/hyperfine/export/csv.rs +++ b/src/hyperfine/export/csv.rs @@ -11,7 +11,7 @@ use csv::WriterBuilder; pub struct CsvExporter {} impl Exporter for CsvExporter { - fn serialize(&self, results: &Vec, _unit: Option) -> Result> { + fn serialize(&self, results: &[BenchmarkResult], _unit: Option) -> Result> { let mut writer = WriterBuilder::new().from_writer(vec![]); for res in results { // The list of times cannot be exported to the CSV file - remove it: diff --git a/src/hyperfine/export/json.rs b/src/hyperfine/export/json.rs index 01da670..85e6949 100644 --- a/src/hyperfine/export/json.rs +++ b/src/hyperfine/export/json.rs @@ -9,14 +9,14 @@ use serde_json::to_vec_pretty; #[derive(Serialize, Debug)] struct HyperfineSummary<'a> { - results: &'a Vec, + results: &'a [BenchmarkResult], } #[derive(Default)] pub struct JsonExporter {} impl Exporter for JsonExporter { - fn serialize(&self, results: &Vec, _unit: Option) -> Result> { + fn serialize(&self, results: &[BenchmarkResult], _unit: Option) -> Result> { let mut output = to_vec_pretty(&HyperfineSummary { results }); for content in output.iter_mut() { content.push(b'\n'); diff --git a/src/hyperfine/export/markdown.rs b/src/hyperfine/export/markdown.rs index 9e75d30..46494e6 100644 --- a/src/hyperfine/export/markdown.rs +++ b/src/hyperfine/export/markdown.rs @@ -11,7 +11,7 @@ use std::io::Result; pub struct MarkdownExporter {} impl Exporter for MarkdownExporter { - fn serialize(&self, results: &Vec, unit: Option) -> Result> { + fn serialize(&self, results: &[BenchmarkResult], unit: Option) -> Result> { let unit = if let Some(unit) = unit { // Use the given unit for all entries. unit @@ -23,7 +23,7 @@ impl Exporter for MarkdownExporter { Unit::Second }; - let annotated_results = compute_relative_speed(&results); + let annotated_results = compute_relative_speed(results); let mut destination = start_table(unit); diff --git a/src/hyperfine/export/mod.rs b/src/hyperfine/export/mod.rs index d6825e3..2ae94b6 100644 --- a/src/hyperfine/export/mod.rs +++ b/src/hyperfine/export/mod.rs @@ -33,7 +33,7 @@ pub enum ExportType { /// Interface for different exporters. trait Exporter { /// Export the given entries in the serialized form. - fn serialize(&self, results: &Vec, unit: Option) -> Result>; + fn serialize(&self, results: &[BenchmarkResult], unit: Option) -> Result>; } struct ExporterWithFilename { @@ -79,7 +79,7 @@ impl ExportManager { } /// Write the given content to a file with the specified name -fn write_to_file(filename: &String, content: &Vec) -> Result<()> { +fn write_to_file(filename: &String, content: &[u8]) -> Result<()> { let mut file = File::create(filename)?; file.write_all(content) } diff --git a/src/hyperfine/internal.rs b/src/hyperfine/internal.rs index 3003107..973a42b 100644 --- a/src/hyperfine/internal.rs +++ b/src/hyperfine/internal.rs @@ -57,7 +57,7 @@ fn compare_mean_time(l: &BenchmarkResult, r: &BenchmarkResult) -> Ordering { } pub fn compute_relative_speed<'a>( - results: &'a Vec, + results: &'a [BenchmarkResult], ) -> Vec> { let fastest: &BenchmarkResult = results .iter() @@ -84,7 +84,7 @@ pub fn compute_relative_speed<'a>( .collect() } -pub fn write_benchmark_comparison(results: &Vec) { +pub fn write_benchmark_comparison(results: &[BenchmarkResult]) { if results.len() < 2 { return; } diff --git a/src/main.rs b/src/main.rs index 2cbc225..0c56b89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,7 @@ pub fn error(message: &str) -> ! { /// Runs the benchmark for the given commands fn run( - commands: &Vec>, + commands: &[Command<'_>], options: &HyperfineOptions, ) -> io::Result> { let shell_spawning_time =