Skip to content
Myr

Refactor MarkdownExporter emitting using a generic MarkupFormatter trait

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* see: https://github.com/sharkdp/hyperfine/pull/490#issuecomment-1076784074

authored by Philipp Paulweber · committed by David Peter · parent 50cf7de · Browse files · 3 files+335 added−312 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+335 added−312 removed

  • other:+335 added−312 removed

3 files+335 added−312 removed

modified:src/export/markdown.rs+68 added-29 removed
1use super::Exporter;2use crate::benchmark::benchmark_result::BenchmarkResult;3use crate::benchmark::relative_speed;4use crate::export::markup::markup_results;5use crate::export::markup::markup_table;6use crate::export::markup::markup_unit;7use crate::export::markup::MarkupType;4use crate::export::markup::MarkupFormatter;5use crate::util::units::Unit;67use anyhow::{anyhow, Result};89#[derive(Default)]10pub struct MarkdownFormatter;1112impl MarkupFormatter for MarkdownFormatter {13 fn table_data(&self, data: &[&str]) -> String {14 format!("| {} |\n", data.join(" | "))15 }1617 fn table_line(&self, size: usize) -> String {18 format!("|:---|{}\n", "---:|".repeat(size - 1))19 }2021 fn command(&self, cmd: &str) -> String {22 format!("`{}`", cmd)23 }24}2526#[derive(Default)]27pub struct MarkdownExporter {}2829impl Exporter for MarkdownExporter {30 fn serialize(&self, results: &[BenchmarkResult], unit: Option<Unit>) -> Result<Vec<u8>> {31 let unit = self.unit(results, unit);32 let entries = relative_speed::compute(results);33 if entries.is_none() {34 return Err(anyhow!(35 "Relative speed comparison is not available for Markdown export."36 ));37 }3824 let kind = MarkupType::Markdown;25 let unit = markup_unit(results, unit);26 let data = markup_results(&kind, &entries.unwrap(), unit);27 let table = markup_table(&kind, &data);39 let formatter = MarkdownFormatter::default();40 let data_vvs = formatter.results(&entries.unwrap(), unit);41 let data_vas: Vec<Vec<&str>> = data_vvs42 .iter()43 .map(|list| list.iter().map(AsRef::as_ref).collect::<Vec<&str>>())44 .collect();45 let data: Vec<&[&str]> = data_vas.iter().map(AsRef::as_ref).collect();46 let table = formatter.table(&data);47 Ok(table.as_bytes().to_vec())48 }49}5051/// Check Markdown-based data row formatting52#[test]53fn test_markdown_formatter_table_data() {54 let formatter = MarkdownFormatter::default();55 let data = vec!["a", "b", "c"];5657 let actual = formatter.table_data(&data);58 let expect = "| a | b | c |\n";5960 assert_eq!(expect, actual);61}6263/// Check Markdown-based horizontal line formatting64#[test]65fn test_markdown_formatter_table_line() {66 let formatter = MarkdownFormatter::default();67 let size = 5;6869 let actual = formatter.table_line(size);70 let expect = "|:---|---:|---:|---:|---:|\n";7172 assert_eq!(expect, actual);73}7475/// Test helper function to create unit-based header and horizontal line76/// independently from the markup functionality for Markdown.77#[cfg(test)]35fn test_table_header(unit_short_name: String) -> String {78fn cfg_test_table_header(unit_short_name: String) -> String {79 format!(80 "| Command | Mean [{unit}] | Min [{unit}] | Max [{unit}] | Relative |\n|:---|---:|---:|---:|---:|\n",81 unit = unit_short_name82 )
38 unmodified lines
121 parameters: BTreeMap::new(),122 },123 ];12482 let formatted = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();8384 let formatted_expected = format!(125 let actual = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();126 let expect = format!(127 "{}\128| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |129| `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |130",89 test_table_header("ms".to_string())131 cfg_test_table_header("ms".to_string())132 );13392 assert_eq!(formatted_expected, formatted);134 assert_eq!(expect, actual);135}136137/// This (again) demonstrates that the first entry's units (s) are used to set138/// the units for all entries when the time unit is not given.
30 unmodified lines
169 parameters: BTreeMap::new(),170 },171 ];172131 let formatted = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();132133 let formatted_expected = format!(173 let actual = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();174 let expect = format!(175 "{}\176| `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |177| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |178",138 test_table_header("s".to_string())179 cfg_test_table_header("s".to_string())180 );181141 assert_eq!(formatted_expected, formatted);182 assert_eq!(expect, actual);183}184185/// The given time unit (s) is used to set the units for all entries.186#[test]
29 unmodified lines
216 parameters: BTreeMap::new(),217 },218 ];219179 let formatted = String::from_utf8(220 let actual = String::from_utf8(221 exporter222 .serialize(&timing_results, Some(Unit::Second))223 .unwrap(),224 )225 .unwrap();185186 let formatted_expected = format!(226 let expect = format!(227 "{}\228| `sleep 0.1` | 0.106 ± 0.002 | 0.102 | 0.108 | 1.00 |229| `sleep 2` | 2.005 ± 0.002 | 2.002 | 2.008 | 18.97 ± 0.29 |230",191 test_table_header("s".to_string())231 cfg_test_table_header("s".to_string())232 );233194 assert_eq!(formatted_expected, formatted);234 assert_eq!(expect, actual);235}236237/// This (again) demonstrates that the given time unit (ms) is used to set238/// the units for all entries.
30 unmodified lines
269 parameters: BTreeMap::new(),270 },271 ];272233 let formatted = String::from_utf8(273 let actual = String::from_utf8(274 exporter275 .serialize(&timing_results, Some(Unit::MilliSecond))276 .unwrap(),277 )278 .unwrap();239240 let formatted_expected = format!(279 let expect = format!(280 "{}\281| `sleep 2` | 2005.0 ± 2.0 | 2002.0 | 2008.0 | 18.97 ± 0.29 |282| `sleep 0.1` | 105.7 ± 1.6 | 102.3 | 108.0 | 1.00 |283",245 test_table_header("ms".to_string())284 cfg_test_table_header("ms".to_string())285 );286248 assert_eq!(formatted_expected, formatted);287 assert_eq!(expect, actual);288}
modified:src/export/markup.rs+61 added-283 removed
1use crate::benchmark::benchmark_result::BenchmarkResult;1use crate::benchmark::relative_speed::BenchmarkResultWithRelativeSpeed;2use crate::output::format::format_duration_value;3use crate::util::units::Unit;46#[derive(Clone)]7pub enum MarkupType {8 /// Markdown table9 Markdown,10}5pub trait MarkupFormatter {6 fn table(&self, data: &[&[&str]]) -> String {7 let head: &[&str] = data.first().unwrap();8 let tail = &data[1..];912pub fn markup_table(kind: &MarkupType, data: &[Vec<String>]) -> String {13 let head: &Vec<String> = data.first().unwrap();14 let tail: &[Vec<String>] = &data[1..];10 // emit header11 let table = &mut self.table_data(head);1216 // emit header17 let mut table = markup_table_data(&kind, head);13 // emit horizontal line14 table.push_str(&self.table_line(head.len()));1519 // emit horizontal line20 table.push_str(&markup_table_line(&kind, head.len()));16 // emit data rows17 for row in tail {18 table.push_str(&self.table_data(row))19 }2022 // emit data rows23 for row in tail {24 table.push_str(&markup_table_data(&kind, row))21 table.to_string()22 }2327 return table;28}24 fn table_data(&self, data: &[&str]) -> String;2530fn markup_table_data(kind: &MarkupType, data: &Vec<String>) -> String {31 return match kind {32 MarkupType::Markdown => format!("| {} |\n", data.join(" | ")),33 };34}26 fn table_line(&self, size: usize) -> String;2736fn markup_table_line(kind: &MarkupType, size: usize) -> String {37 return match kind {38 MarkupType::Markdown => format!("|:---|{}\n", "---:|".repeat(size - 1)),39 };40}28 fn command(&self, size: &str) -> String;2942pub fn markup_results(43 kind: &MarkupType,44 entries: &[BenchmarkResultWithRelativeSpeed],45 unit: Unit,46) -> Vec<Vec<String>> {47 // prepare table header strings48 let notation = format!("[{}]", unit.short_name());49 let mut data: Vec<Vec<_>> = vec![vec![50 format!("Command"),51 format!("Mean {}", notation),52 format!("Min {}", notation),53 format!("Max {}", notation),54 format!("Relative"),55 ]];30 fn results(31 &self,32 entries: &[BenchmarkResultWithRelativeSpeed],33 unit: Unit,34 ) -> Vec<Vec<String>> {35 // prepare table header strings36 let notation = format!("[{}]", unit.short_name());37 let mut data: Vec<Vec<_>> = vec![vec![38 "Command".to_string(),39 format!("Mean {}", notation),40 format!("Min {}", notation),41 format!("Max {}", notation),42 "Relative".to_string(),43 ]];4457 for entry in entries {58 let measurement = &entry.result;59 // prepare data row strings60 let cmd_str = measurement.command.replace("|", "\\|");61 let mean_str = format_duration_value(measurement.mean, Some(unit)).0;62 let stddev_str = if let Some(stddev) = measurement.stddev {63 format!(" ± {}", format_duration_value(stddev, Some(unit)).0)64 } else {65 "".into()66 };67 let min_str = format_duration_value(measurement.min, Some(unit)).0;68 let max_str = format_duration_value(measurement.max, Some(unit)).0;69 let rel_str = format!("{:.2}", entry.relative_speed);70 let rel_stddev_str = if entry.is_fastest {71 "".into()72 } else if let Some(stddev) = entry.relative_speed_stddev {73 format!(" ± {:.2}", stddev)74 } else {75 "".into()76 };77 // prepare table row entries78 data.push(vec![79 match kind {80 MarkupType::Markdown => format!("`{}`", cmd_str),81 },82 format!("{}{}", mean_str, stddev_str),83 format!("{}", min_str),84 format!("{}", max_str),85 format!("{}{}", rel_str, rel_stddev_str),86 ])87 }45 for entry in entries {46 let measurement = &entry.result;47 // prepare data row strings48 let cmd_str = measurement.command.replace('|', "\\|");49 let mean_str = format_duration_value(measurement.mean, Some(unit)).0;50 let stddev_str = if let Some(stddev) = measurement.stddev {51 format!(" ± {}", format_duration_value(stddev, Some(unit)).0)52 } else {53 "".into()54 };55 let min_str = format_duration_value(measurement.min, Some(unit)).0;56 let max_str = format_duration_value(measurement.max, Some(unit)).0;57 let rel_str = format!("{:.2}", entry.relative_speed);58 let rel_stddev_str = if entry.is_fastest {59 "".into()60 } else if let Some(stddev) = entry.relative_speed_stddev {61 format!(" ± {:.2}", stddev)62 } else {63 "".into()64 };65 // prepare table row entries66 data.push(vec![67 self.command(&cmd_str),68 format!("{}{}", mean_str, stddev_str),69 min_str,70 max_str,71 format!("{}{}", rel_str, rel_stddev_str),72 ])73 }7489 return data;75 data76 }77}9192pub fn markup_unit(results: &[BenchmarkResult], unit: Option<Unit>) -> Unit {93 return if let Some(unit) = unit {94 // Use the given unit for all entries.95 unit96 } else if let Some(first_result) = results.first() {97 // Use the first BenchmarkResult entry to determine the unit for all entries.98 format_duration_value(first_result.mean, None).199 } else {100 // Default to `Second`.101 Unit::Second102 };103}104105/// Check Markdown-based data row formatting106#[test]107fn test_markup_table_data_markdown() {108 let kind = MarkupType::Markdown;109 let data: Vec<_> = vec!["a", "b", "c"].into_iter().map(String::from).collect();110111 let markup_actual = markup_table_data(&kind, &data);112 let markup_expected = format!("| a | b | c |\n");113114 assert_eq!(markup_expected, markup_actual);115}116117/// Check Markdown-based horizontal line formatting118#[test]119fn test_markup_table_line_markdown() {120 let kind = MarkupType::Markdown;121 let size = 5;122123 let markup_actual = markup_table_line(&kind, size);124 let markup_expected = format!("|:---|---:|---:|---:|---:|\n");125126 assert_eq!(markup_expected, markup_actual);127}128129/// Check unit resolving for timing results and given unit 's'130#[test]131fn test_markup_table_unit_given_s() {132 use std::collections::BTreeMap;133 let results = vec![134 BenchmarkResult {135 command: String::from("sleep 2"),136 mean: 2.0050,137 stddev: Some(0.0020),138 median: 2.0050,139 user: 0.0009,140 system: 0.0012,141 min: 2.0020,142 max: 2.0080,143 times: Some(vec![2.0, 2.0, 2.0]),144 exit_codes: vec![Some(0), Some(0), Some(0)],145 parameters: BTreeMap::new(),146 },147 BenchmarkResult {148 command: String::from("sleep 0.1"),149 mean: 0.1057,150 stddev: Some(0.0016),151 median: 0.1057,152 user: 0.0009,153 system: 0.0011,154 min: 0.1023,155 max: 0.1080,156 times: Some(vec![0.1, 0.1, 0.1]),157 exit_codes: vec![Some(0), Some(0), Some(0)],158 parameters: BTreeMap::new(),159 },160 ];161 let unit = Some(Unit::Second);162163 let markup_actual = markup_unit(&results, unit);164 let markup_expected = Unit::Second;165166 assert_eq!(markup_expected, markup_actual);167}168169/// Check unit resolving for timing results and given unit 'ms'170#[test]171fn test_markup_table_unit_given_ms() {172 use std::collections::BTreeMap;173 let results = vec![174 BenchmarkResult {175 command: String::from("sleep 2"),176 mean: 2.0050,177 stddev: Some(0.0020),178 median: 2.0050,179 user: 0.0009,180 system: 0.0012,181 min: 2.0020,182 max: 2.0080,183 times: Some(vec![2.0, 2.0, 2.0]),184 exit_codes: vec![Some(0), Some(0), Some(0)],185 parameters: BTreeMap::new(),186 },187 BenchmarkResult {188 command: String::from("sleep 0.1"),189 mean: 0.1057,190 stddev: Some(0.0016),191 median: 0.1057,192 user: 0.0009,193 system: 0.0011,194 min: 0.1023,195 max: 0.1080,196 times: Some(vec![0.1, 0.1, 0.1]),197 exit_codes: vec![Some(0), Some(0), Some(0)],198 parameters: BTreeMap::new(),199 },200 ];201 let unit = Some(Unit::MilliSecond);202203 let markup_actual = markup_unit(&results, unit);204 let markup_expected = Unit::MilliSecond;205206 assert_eq!(markup_expected, markup_actual);207}208209/// Check unit resolving for timing results using the first result entry as 's'210#[test]211fn test_markup_table_unit_first_s() {212 use std::collections::BTreeMap;213 let results = vec![214 BenchmarkResult {215 command: String::from("sleep 2"),216 mean: 2.0050,217 stddev: Some(0.0020),218 median: 2.0050,219 user: 0.0009,220 system: 0.0012,221 min: 2.0020,222 max: 2.0080,223 times: Some(vec![2.0, 2.0, 2.0]),224 exit_codes: vec![Some(0), Some(0), Some(0)],225 parameters: BTreeMap::new(),226 },227 BenchmarkResult {228 command: String::from("sleep 0.1"),229 mean: 0.1057,230 stddev: Some(0.0016),231 median: 0.1057,232 user: 0.0009,233 system: 0.0011,234 min: 0.1023,235 max: 0.1080,236 times: Some(vec![0.1, 0.1, 0.1]),237 exit_codes: vec![Some(0), Some(0), Some(0)],238 parameters: BTreeMap::new(),239 },240 ];241 let unit = None;242243 let markup_actual = markup_unit(&results, unit);244 let markup_expected = Unit::Second;245246 assert_eq!(markup_expected, markup_actual);247}248249/// Check unit resolving for timing results using the first result entry as 'ms'250#[test]251fn test_markup_table_unit_first_ms() {252 use std::collections::BTreeMap;253 let results = vec![254 BenchmarkResult {255 command: String::from("sleep 0.1"),256 mean: 0.1057,257 stddev: Some(0.0016),258 median: 0.1057,259 user: 0.0009,260 system: 0.0011,261 min: 0.1023,262 max: 0.1080,263 times: Some(vec![0.1, 0.1, 0.1]),264 exit_codes: vec![Some(0), Some(0), Some(0)],265 parameters: BTreeMap::new(),266 },267 BenchmarkResult {268 command: String::from("sleep 2"),269 mean: 2.0050,270 stddev: Some(0.0020),271 median: 2.0050,272 user: 0.0009,273 system: 0.0012,274 min: 2.0020,275 max: 2.0080,276 times: Some(vec![2.0, 2.0, 2.0]),277 exit_codes: vec![Some(0), Some(0), Some(0)],278 parameters: BTreeMap::new(),279 },280 ];281 let unit = None;282283 let markup_actual = markup_unit(&results, unit);284 let markup_expected = Unit::MilliSecond;285286 assert_eq!(markup_expected, markup_actual);287}288289/// Check unit resolving for not timing results and no given unit defaulting to 's'290#[test]291fn test_markup_table_unit_default_s() {292 let results: Vec<BenchmarkResult> = vec![];293 let unit = None;294295 let markup_actual = markup_unit(&results, unit);296 let markup_expected = Unit::Second;297298 assert_eq!(markup_expected, markup_actual);299}
modified:src/export/mod.rs+206 added
11 unmodified lines
12use self::json::JsonExporter;13use self::markdown::MarkdownExporter;1415use crate::benchmark::benchmark_result::BenchmarkResult;16use crate::output::format::format_duration_value;17use crate::util::units::Unit;1819use anyhow::{Context, Result};20use clap::ArgMatches;
17 unmodified lines
38/// Interface for different exporters.39trait Exporter {40 /// Export the given entries in the serialized form.41 fn serialize(&self, results: &[BenchmarkResult], unit: Option<Unit>) -> Result<Vec<u8>>;4243 fn unit(&self, results: &[BenchmarkResult], unit: Option<Unit>) -> Unit {44 return if let Some(unit) = unit {45 // Use the given unit for all entries.46 unit47 } else if let Some(first_result) = results.first() {48 // Use the first BenchmarkResult entry to determine the unit for all entries.49 format_duration_value(first_result.mean, None).150 } else {51 // Default to `Second`.52 Unit::Second53 };54 }55}5657struct ExporterWithFilename {58 exporter: Box<dyn Exporter>,
60 unmodified lines
119 let mut file = OpenOptions::new().write(true).open(filename)?;120 file.write_all(content)121 .with_context(|| format!("Failed to export results to '{}'", filename))122}123124#[cfg(test)]125#[derive(Default)]126struct TestExporter;127128#[cfg(test)]129impl Exporter for TestExporter {130 fn serialize(&self, _results: &[BenchmarkResult], _unit: Option<Unit>) -> Result<Vec<u8>> {131 assert_eq!(132 "",133 "This 'Exporter' trait implementation shall only be used to test the 'unit' function!"134 );135 Ok(vec![])136 }137}138139/// Check unit resolving for timing results and given unit 's'140#[test]141fn test_markup_table_unit_given_s() {142 use std::collections::BTreeMap;143 let results = vec![144 BenchmarkResult {145 command: String::from("sleep 2"),146 mean: 2.0050,147 stddev: Some(0.0020),148 median: 2.0050,149 user: 0.0009,150 system: 0.0012,151 min: 2.0020,152 max: 2.0080,153 times: Some(vec![2.0, 2.0, 2.0]),154 exit_codes: vec![Some(0), Some(0), Some(0)],155 parameters: BTreeMap::new(),156 },157 BenchmarkResult {158 command: String::from("sleep 0.1"),159 mean: 0.1057,160 stddev: Some(0.0016),161 median: 0.1057,162 user: 0.0009,163 system: 0.0011,164 min: 0.1023,165 max: 0.1080,166 times: Some(vec![0.1, 0.1, 0.1]),167 exit_codes: vec![Some(0), Some(0), Some(0)],168 parameters: BTreeMap::new(),169 },170 ];171 let unit = Some(Unit::Second);172173 let exporter = TestExporter::default();174 let markup_actual = exporter.unit(&results, unit);175 let markup_expected = Unit::Second;176177 assert_eq!(markup_expected, markup_actual);178}179180/// Check unit resolving for timing results and given unit 'ms'181#[test]182fn test_markup_table_unit_given_ms() {183 use std::collections::BTreeMap;184 let results = vec![185 BenchmarkResult {186 command: String::from("sleep 2"),187 mean: 2.0050,188 stddev: Some(0.0020),189 median: 2.0050,190 user: 0.0009,191 system: 0.0012,192 min: 2.0020,193 max: 2.0080,194 times: Some(vec![2.0, 2.0, 2.0]),195 exit_codes: vec![Some(0), Some(0), Some(0)],196 parameters: BTreeMap::new(),197 },198 BenchmarkResult {199 command: String::from("sleep 0.1"),200 mean: 0.1057,201 stddev: Some(0.0016),202 median: 0.1057,203 user: 0.0009,204 system: 0.0011,205 min: 0.1023,206 max: 0.1080,207 times: Some(vec![0.1, 0.1, 0.1]),208 exit_codes: vec![Some(0), Some(0), Some(0)],209 parameters: BTreeMap::new(),210 },211 ];212 let unit = Some(Unit::MilliSecond);213214 let exporter = TestExporter::default();215 let markup_actual = exporter.unit(&results, unit);216 let markup_expected = Unit::MilliSecond;217218 assert_eq!(markup_expected, markup_actual);219}220221/// Check unit resolving for timing results using the first result entry as 's'222#[test]223fn test_markup_table_unit_first_s() {224 use std::collections::BTreeMap;225 let results = vec![226 BenchmarkResult {227 command: String::from("sleep 2"),228 mean: 2.0050,229 stddev: Some(0.0020),230 median: 2.0050,231 user: 0.0009,232 system: 0.0012,233 min: 2.0020,234 max: 2.0080,235 times: Some(vec![2.0, 2.0, 2.0]),236 exit_codes: vec![Some(0), Some(0), Some(0)],237 parameters: BTreeMap::new(),238 },239 BenchmarkResult {240 command: String::from("sleep 0.1"),241 mean: 0.1057,242 stddev: Some(0.0016),243 median: 0.1057,244 user: 0.0009,245 system: 0.0011,246 min: 0.1023,247 max: 0.1080,248 times: Some(vec![0.1, 0.1, 0.1]),249 exit_codes: vec![Some(0), Some(0), Some(0)],250 parameters: BTreeMap::new(),251 },252 ];253 let unit = None;254255 let exporter = TestExporter::default();256 let markup_actual = exporter.unit(&results, unit);257 let markup_expected = Unit::Second;258259 assert_eq!(markup_expected, markup_actual);260}261262/// Check unit resolving for timing results using the first result entry as 'ms'263#[test]264fn test_markup_table_unit_first_ms() {265 use std::collections::BTreeMap;266 let results = vec![267 BenchmarkResult {268 command: String::from("sleep 0.1"),269 mean: 0.1057,270 stddev: Some(0.0016),271 median: 0.1057,272 user: 0.0009,273 system: 0.0011,274 min: 0.1023,275 max: 0.1080,276 times: Some(vec![0.1, 0.1, 0.1]),277 exit_codes: vec![Some(0), Some(0), Some(0)],278 parameters: BTreeMap::new(),279 },280 BenchmarkResult {281 command: String::from("sleep 2"),282 mean: 2.0050,283 stddev: Some(0.0020),284 median: 2.0050,285 user: 0.0009,286 system: 0.0012,287 min: 2.0020,288 max: 2.0080,289 times: Some(vec![2.0, 2.0, 2.0]),290 exit_codes: vec![Some(0), Some(0), Some(0)],291 parameters: BTreeMap::new(),292 },293 ];294 let unit = None;295296 let exporter = TestExporter::default();297 let markup_actual = exporter.unit(&results, unit);298 let markup_expected = Unit::MilliSecond;299300 assert_eq!(markup_expected, markup_actual);301}302303/// Check unit resolving for not timing results and no given unit defaulting to 's'304#[test]305fn test_markup_table_unit_default_s() {306 let results: Vec<BenchmarkResult> = vec![];307 let unit = None;308309 let exporter = TestExporter::default();310 let markup_actual = exporter.unit(&results, unit);311 let markup_expected = Unit::Second;312313 assert_eq!(markup_expected, markup_actual);314}