diff options
Diffstat (limited to 'src/metrics.h')
-rw-r--r-- | src/metrics.h | 7 |
1 files changed, 7 insertions, 0 deletions
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_ |