Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize command parameters to data output files #131

Merged
merged 1 commit into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/hyperfine/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,5 +412,6 @@ pub fn run_benchmark(
t_min,
t_max,
times_real,
cmd.get_parameter().map(|p| p.1),
))
}
8 changes: 8 additions & 0 deletions src/hyperfine/export/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ fn test_markdown_format_ms() {
0.1023, // min
0.1080, // max
vec![0.1, 0.1, 0.1], // times
None, // parameter
));

timing_results.push(BenchmarkResult::new(
Expand All @@ -94,6 +95,7 @@ fn test_markdown_format_ms() {
2.0020, // min
2.0080, // max
vec![2.0, 2.0, 2.0], // times
None, // parameter
));

let formatted = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();
Expand Down Expand Up @@ -126,6 +128,7 @@ fn test_markdown_format_s() {
2.0020, // min
2.0080, // max
vec![2.0, 2.0, 2.0], // times
None, // parameter
));

timing_results.push(BenchmarkResult::new(
Expand All @@ -137,6 +140,7 @@ fn test_markdown_format_s() {
0.1023, // min
0.1080, // max
vec![0.1, 0.1, 0.1], // times
None, // parameter
));

let formatted = String::from_utf8(exporter.serialize(&timing_results, None).unwrap()).unwrap();
Expand Down Expand Up @@ -168,6 +172,7 @@ fn test_markdown_format_time_unit_s() {
0.1023, // min
0.1080, // max
vec![0.1, 0.1, 0.1], // times
None, // parameter
));

timing_results.push(BenchmarkResult::new(
Expand All @@ -179,6 +184,7 @@ fn test_markdown_format_time_unit_s() {
2.0020, // min
2.0080, // max
vec![2.0, 2.0, 2.0], // times
None, // parameter
));

let formatted = String::from_utf8(
Expand Down Expand Up @@ -216,6 +222,7 @@ fn test_markdown_format_time_unit_ms() {
2.0020, // min
2.0080, // max
vec![2.0, 2.0, 2.0], // times
None, // parameter
));

timing_results.push(BenchmarkResult::new(
Expand All @@ -227,6 +234,7 @@ fn test_markdown_format_time_unit_ms() {
0.1023, // min
0.1080, // max
vec![0.1, 0.1, 0.1], // times
None, // parameter
));

let formatted = String::from_utf8(
Expand Down
6 changes: 6 additions & 0 deletions src/hyperfine/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ pub struct BenchmarkResult {
/// All run time measurements
#[serde(skip_serializing_if = "Option::is_none")]
pub times: Option<Vec<Second>>,

/// Any parameter used
#[serde(skip_serializing_if = "Option::is_none")]
pub parameter: Option<i32>,
}

impl BenchmarkResult {
Expand All @@ -186,6 +190,7 @@ impl BenchmarkResult {
min: Second,
max: Second,
times: Vec<Second>,
parameter: Option<i32>,
) -> Self {
BenchmarkResult {
command,
Expand All @@ -196,6 +201,7 @@ impl BenchmarkResult {
min,
max,
times: Some(times),
parameter,
}
}
}