Ninja
Classes | Macros | Functions | Variables
metrics.h File Reference
#include <string>
#include <vector>
#include "util.h"
Include dependency graph for metrics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Metric
 The Metrics module is used for the debug mode that dumps timing stats of various actions. More...
 
struct  Metrics
 The singleton that stores metrics and prints the report. More...
 
struct  ScopedMetric
 A scoped object for recording a metric across the body of a function. More...
 
struct  Stopwatch
 A simple stopwatch which returns the time in seconds since Restart() was called. More...
 

Macros

#define METRIC_RECORD(name)
 The primary interface to metrics. More...
 
#define METRIC_RECORD_IF(name, condition)
 A variant of METRIC_RECORD that doesn't record anything if |condition| is false. More...
 

Functions

int64_t GetTimeMillis ()
 Get the current time as relative to some epoch. More...
 

Variables

Metricsg_metrics
 

Macro Definition Documentation

◆ METRIC_RECORD

#define METRIC_RECORD (   name)
Value:
static Metric* metrics_h_metric = \
g_metrics ? g_metrics->NewMetric(name) : NULL; \
ScopedMetric metrics_h_scoped(metrics_h_metric);
Metrics * g_metrics
Definition: metrics.cc:28
The Metrics module is used for the debug mode that dumps timing stats of various actions.
Definition: metrics.h:27
Metric * NewMetric(const std::string &name)
Definition: metrics.cc:73

The primary interface to metrics.

Use METRIC_RECORD("foobar") at the top of a function to get timing stats recorded for each call of the function.

Definition at line 83 of file metrics.h.

◆ METRIC_RECORD_IF

#define METRIC_RECORD_IF (   name,
  condition 
)
Value:
static Metric* metrics_h_metric = \
g_metrics ? g_metrics->NewMetric(name) : NULL; \
ScopedMetric metrics_h_scoped((condition) ? metrics_h_metric : NULL);

A variant of METRIC_RECORD that doesn't record anything if |condition| is false.

Definition at line 90 of file metrics.h.

Function Documentation

◆ GetTimeMillis()

int64_t GetTimeMillis ( )

Get the current time as relative to some epoch.

Epoch varies between platforms; only useful for measuring elapsed time.

Definition at line 111 of file metrics.cc.

Referenced by Builder::FinishCommand(), main(), and Builder::StartEdge().

Variable Documentation

◆ g_metrics

Metrics* g_metrics
extern

Definition at line 28 of file metrics.cc.