Skip to content

Commit

Permalink
Merge pull request #2292 from digit-google/fix-stats-report
Browse files Browse the repository at this point in the history
Fix stats report
  • Loading branch information
jhasse authored Nov 22, 2023
2 parents e64ed58 + cff9dce commit 82a7cb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
5 changes: 4 additions & 1 deletion src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) !=
Expand Down

0 comments on commit 82a7cb3

Please sign in to comment.