formtating

This commit is contained in:
Richard Montoya 2023-07-28 19:39:41 -05:00
parent c8bfd59d81
commit 539995aad1
4 changed files with 9 additions and 8 deletions

View File

@ -1,13 +1,13 @@
use std::collections::BTreeMap;
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
use crate::util::units::Second;
/// Set of values that will be exported.
// NOTE: `serde` is used for JSON serialization, but not for CSV serialization due to the
// `parameters` map. Update `src/hyperfine/export/csv.rs` with new fields, as appropriate.
#[derive(Debug, Default, Clone, Serialize, Deserialize ,PartialEq)]
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
pub struct BenchmarkResult {
/// The full command line of the program that is being benchmarked
pub command: String,

View File

@ -22,7 +22,7 @@ impl<'a> Scheduler<'a> {
commands: &'a Commands,
options: &'a Options,
export_manager: &'a ExportManager,
results: &'a Vec<BenchmarkResult>
results: &'a Vec<BenchmarkResult>,
) -> Self {
Self {
commands,
@ -85,7 +85,6 @@ impl<'a> Scheduler<'a> {
let fastest = annotated_results.iter().find(|r| r.is_fastest).unwrap();
let others = annotated_results.iter().filter(|r| !r.is_fastest);
println!(
" {} ran",
(get_command_from_result(&fastest.result)).cyan()

View File

@ -23,7 +23,9 @@ impl Exporter for JsonExporter {
_unit: Option<Unit>,
_sort_order: SortOrder,
) -> Result<Vec<u8>> {
let mut output = to_vec_pretty(&HyperfineSummary { results: results.to_vec() });
let mut output = to_vec_pretty(&HyperfineSummary {
results: results.to_vec(),
});
if let Ok(ref mut content) = output {
content.push(b'\n');
}

View File

@ -1,6 +1,6 @@
use crate::{benchmark::benchmark_result::BenchmarkResult, export::json::HyperfineSummary};
use clap::ArgMatches;
use std::fs;
use crate::{export::json::HyperfineSummary, benchmark::benchmark_result::BenchmarkResult};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Importer {}
@ -19,8 +19,8 @@ fn read_summary_from_file(file_name: &str) -> Option<Vec<BenchmarkResult>> {
Ok(content) => content,
Err(_) => {
eprintln!("Unable to load previous run from file {}", file_name);
return None
},
return None;
}
};
let hyperfine_summary = serde_json::from_str::<HyperfineSummary>(&file_content);