diff options
author | Jan Niklas Hasse <jhasse@bixense.com> | 2023-11-22 16:25:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 16:25:53 (GMT) |
commit | 82a7cb3f263a6af7cc4c24408cf0a4ca5b648b55 (patch) | |
tree | 8e256abea0edd39c5143fe61bee8e0dcc88aabb4 | |
parent | e64ed58d68d394e0be08f4435b507dd7a6e5b510 (diff) | |
parent | cff9dce3cd2187a7671b05d2437a426ca6e06ca0 (diff) | |
download | Ninja-82a7cb3f263a6af7cc4c24408cf0a4ca5b648b55.zip Ninja-82a7cb3f263a6af7cc4c24408cf0a4ca5b648b55.tar.gz Ninja-82a7cb3f263a6af7cc4c24408cf0a4ca5b648b55.tar.bz2 |
Merge pull request #2292 from digit-google/fix-stats-report
Fix stats report
-rw-r--r-- | src/graph.cc | 1 | ||||
-rw-r--r-- | src/metrics.h | 7 | ||||
-rw-r--r-- | src/parser.cc | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/graph.cc b/src/graph.cc index 62f13ec..31b109a 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -32,7 +32,6 @@ using namespace std; bool Node::Stat(DiskInterface* disk_interface, string* err) { - METRIC_RECORD("node stat"); mtime_ = disk_interface->Stat(path_, err); if (mtime_ == -1) { return false; diff --git a/src/metrics.h b/src/metrics.h index c9ba236..937d905 100644 --- a/src/metrics.h +++ b/src/metrics.h @@ -85,6 +85,13 @@ struct Stopwatch { g_metrics ? g_metrics->NewMetric(name) : NULL; \ ScopedMetric metrics_h_scoped(metrics_h_metric); +/// A variant of METRIC_RECORD that doesn't record anything if |condition| +/// is false. +#define METRIC_RECORD_IF(name, condition) \ + static Metric* metrics_h_metric = \ + g_metrics ? g_metrics->NewMetric(name) : NULL; \ + ScopedMetric metrics_h_scoped((condition) ? metrics_h_metric : NULL); + extern Metrics* g_metrics; #endif // NINJA_METRICS_H_ diff --git a/src/parser.cc b/src/parser.cc index 5f303c5..139a347 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -20,7 +20,10 @@ using namespace std; bool Parser::Load(const string& filename, string* err, Lexer* parent) { - METRIC_RECORD(".ninja parse"); + // If |parent| is not NULL, metrics collection has been started by a parent + // Parser::Load() in our call stack. Do not start a new one here to avoid + // over-counting parsing times. + METRIC_RECORD_IF(".ninja parse", parent == NULL); string contents; string read_err; if (file_reader_->ReadFile(filename, &contents, &read_err) != |