diff options
author | Peter Kuemmel <syntheticpp@gmx.net> | 2012-06-29 14:12:03 (GMT) |
---|---|---|
committer | Peter Kümmel <syntheticpp@gmx.net> | 2012-07-15 20:22:27 (GMT) |
commit | c0c5ef9bffb0130e169aeddcb8487b670c6b56fe (patch) | |
tree | 229e624ce902d6f1cf4204c8a55a5abdee73daa6 /src/metrics.h | |
parent | 638b0336e98af65240c1d0d66c5e0d9e5b800d9e (diff) | |
download | Ninja-c0c5ef9bffb0130e169aeddcb8487b670c6b56fe.zip Ninja-c0c5ef9bffb0130e169aeddcb8487b670c6b56fe.tar.gz Ninja-c0c5ef9bffb0130e169aeddcb8487b670c6b56fe.tar.bz2 |
print edges per second
prints the rate of finished edges per second to the console,
for instance with NINJA_STATUS="[%s/%t %o(%c)/s] ":
[132/1922 16.1(14)/s]
16.1 is the average for all processed files (here 132 since start)
14 is the average of the last n files while n is the number specifies by
-j (or its default)
Diffstat (limited to 'src/metrics.h')
-rw-r--r-- | src/metrics.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/metrics.h b/src/metrics.h index af6e9a2..dae6b9f 100644 --- a/src/metrics.h +++ b/src/metrics.h @@ -33,6 +33,7 @@ struct Metric { int64_t sum; }; + /// A scoped object for recording a metric across the body of a function. /// Used by the METRIC_RECORD macro. struct ScopedMetric { @@ -57,6 +58,30 @@ private: vector<Metric*> metrics_; }; +/// Get the current time as relative to some epoch. +/// Epoch varies between platforms; only useful for measuring elapsed +/// time. +int64_t GetTimeMillis(); + + +/// A simple stopwatch which retruns the time +// in seconds since Restart() was called +class Stopwatch +{ +public: + Stopwatch() : started_(0) {} + + /// Seconds since Restart() call + double Elapsed() const { return 1e-6 * (Now() - started_); } + + void Restart() { started_ = Now(); } + +private: + uint64_t started_; + uint64_t Now() const; +}; + + /// 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. #define METRIC_RECORD(name) \ |