mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
performance-metrics: Refactor report file opening code
It should be closer to the use of the opened file. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
d3be855b4b
commit
1004f870e1
@ -464,17 +464,6 @@ fn main() {
|
||||
None => Vec::new(),
|
||||
};
|
||||
|
||||
let mut report_file: Box<dyn std::io::Write + Send> =
|
||||
if let Some(file) = cmd_arguments.value_of("report-file") {
|
||||
Box::new(
|
||||
std::fs::File::create(std::path::Path::new(file))
|
||||
.map_err(Error::ReportFileCreation)
|
||||
.unwrap(),
|
||||
)
|
||||
} else {
|
||||
Box::new(std::io::stderr())
|
||||
};
|
||||
|
||||
// Run performance tests sequentially and report results (in both readable/json format)
|
||||
let mut metrics_report: MetricsReport = Default::default();
|
||||
|
||||
@ -496,6 +485,17 @@ fn main() {
|
||||
|
||||
cleanup_tests();
|
||||
|
||||
let mut report_file: Box<dyn std::io::Write + Send> =
|
||||
if let Some(file) = cmd_arguments.value_of("report-file") {
|
||||
Box::new(
|
||||
std::fs::File::create(std::path::Path::new(file))
|
||||
.map_err(Error::ReportFileCreation)
|
||||
.unwrap(),
|
||||
)
|
||||
} else {
|
||||
Box::new(std::io::stderr())
|
||||
};
|
||||
|
||||
report_file
|
||||
.write(
|
||||
serde_json::to_string_pretty(&metrics_report)
|
||||
|
Loading…
Reference in New Issue
Block a user