mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
performance-metrics: Log the git information from the working folder
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
d650c684f1
commit
5bd305fa4f
@ -18,32 +18,9 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
let mut git_revision = "".to_string();
|
||||
if let Ok(git_out) = Command::new("git").args(&["rev-parse", "HEAD"]).output() {
|
||||
if git_out.status.success() {
|
||||
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
||||
git_revision = git_out_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut git_committer_date = "".to_string();
|
||||
if let Ok(git_out) = Command::new("git")
|
||||
.args(&["show", "-s", "--format=%cd"])
|
||||
.output()
|
||||
{
|
||||
if git_out.status.success() {
|
||||
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
||||
git_committer_date = git_out_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This println!() has a special behavior, as it will set the environment
|
||||
// variable GIT_human_readable, so that it can be reused from the binary.
|
||||
// variable GIT_HUMAN_READABLE, so that it can be reused from the binary.
|
||||
// Particularly, this is used from the main.rs to display the exact
|
||||
// version information.
|
||||
println!("cargo:rustc-env=GIT_HUMAN_READABLE={}", git_human_readable);
|
||||
println!("cargo:rustc-env=GIT_REVISION={}", git_revision);
|
||||
println!("cargo:rustc-env=GIT_COMMITER_DATE={}", git_committer_date);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ use std::{
|
||||
collections::HashSet,
|
||||
env, fmt,
|
||||
hash::{Hash, Hasher},
|
||||
process::Command,
|
||||
sync::mpsc::channel,
|
||||
thread,
|
||||
time::Duration,
|
||||
@ -50,6 +51,48 @@ pub struct MetricsReport {
|
||||
pub results: Vec<PerformanceTestResult>,
|
||||
}
|
||||
|
||||
impl Default for MetricsReport {
|
||||
fn default() -> Self {
|
||||
let mut git_human_readable = "".to_string();
|
||||
if let Ok(git_out) = Command::new("git").args(&["describe", "--dirty"]).output() {
|
||||
if git_out.status.success() {
|
||||
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
||||
git_human_readable = git_out_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut git_revision = "".to_string();
|
||||
if let Ok(git_out) = Command::new("git").args(&["rev-parse", "HEAD"]).output() {
|
||||
if git_out.status.success() {
|
||||
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
||||
git_revision = git_out_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut git_committer_date = "".to_string();
|
||||
if let Ok(git_out) = Command::new("git")
|
||||
.args(&["show", "-s", "--format=%cd"])
|
||||
.output()
|
||||
{
|
||||
if git_out.status.success() {
|
||||
if let Ok(git_out_str) = String::from_utf8(git_out.stdout) {
|
||||
git_committer_date = git_out_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MetricsReport {
|
||||
git_human_readable,
|
||||
git_revision,
|
||||
git_committer_date,
|
||||
date: date(),
|
||||
results: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PerformanceTestControl {
|
||||
test_time: u32,
|
||||
test_iterations: u32,
|
||||
@ -418,13 +461,7 @@ fn main() {
|
||||
};
|
||||
|
||||
// Run performance tests sequentially and report results (in both readable/json format)
|
||||
let mut metrics_report = MetricsReport {
|
||||
git_human_readable: env!("GIT_HUMAN_READABLE").to_string(),
|
||||
git_revision: env!("GIT_REVISION").to_string(),
|
||||
git_committer_date: env!("GIT_COMMITER_DATE").to_string(),
|
||||
date: date(),
|
||||
results: Vec::new(),
|
||||
};
|
||||
let mut metrics_report: MetricsReport = Default::default();
|
||||
|
||||
init_tests();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user