Rollup merge of #110442 - ferrocene:pa-build-metrics-dry-run, r=ozkanonur

Avoid including dry run steps in the build metrics

Including steps executed during the dry run will result in a duplication of all the steps in the build metrics, which just adds noise.
This commit is contained in:
Matthias Krüger 2023-04-18 06:44:46 +02:00 committed by GitHub
commit 1e3a38438a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 6 deletions

View File

@ -2030,7 +2030,7 @@ impl<'a> Builder<'a> {
}
#[cfg(feature = "build-metrics")]
self.metrics.enter_step(&step);
self.metrics.enter_step(&step, self);
let (out, dur) = {
let start = Instant::now();
@ -2056,7 +2056,7 @@ impl<'a> Builder<'a> {
}
#[cfg(feature = "build-metrics")]
self.metrics.exit_step();
self.metrics.exit_step(self);
{
let mut stack = self.stack.borrow_mut();

View File

@ -4,7 +4,7 @@
//! As this module requires additional dependencies not present during local builds, it's cfg'd
//! away whenever the `build.metrics` config option is not set to `true`.
use crate::builder::Step;
use crate::builder::{Builder, Step};
use crate::util::t;
use crate::Build;
use serde_derive::{Deserialize, Serialize};
@ -33,7 +33,12 @@ impl BuildMetrics {
BuildMetrics { state }
}
pub(crate) fn enter_step<S: Step>(&self, step: &S) {
pub(crate) fn enter_step<S: Step>(&self, step: &S, builder: &Builder<'_>) {
// Do not record dry runs, as they'd be duplicates of the actual steps.
if builder.config.dry_run() {
return;
}
let mut state = self.state.borrow_mut();
// Consider all the stats gathered so far as the parent's.
@ -56,7 +61,12 @@ impl BuildMetrics {
});
}
pub(crate) fn exit_step(&self) {
pub(crate) fn exit_step(&self, builder: &Builder<'_>) {
// Do not record dry runs, as they'd be duplicates of the actual steps.
if builder.config.dry_run() {
return;
}
let mut state = self.state.borrow_mut();
self.collect_stats(&mut *state);
@ -74,7 +84,12 @@ impl BuildMetrics {
}
}
pub(crate) fn record_test(&self, name: &str, outcome: TestOutcome) {
pub(crate) fn record_test(&self, name: &str, outcome: TestOutcome, builder: &Builder<'_>) {
// Do not record dry runs, as they'd be duplicates of the actual steps.
if builder.config.dry_run() {
return;
}
let mut state = self.state.borrow_mut();
state
.running_steps

View File

@ -124,6 +124,7 @@ impl<'a> Renderer<'a> {
ignore_reason: reason.map(|s| s.to_string()),
},
},
self.builder,
);
if self.builder.config.verbose_tests {