summaryrefslogtreecommitdiffstats
path: root/src/build.h
diff options
context:
space:
mode:
authorPeter Kuemmel <syntheticpp@gmx.net>2012-06-29 14:12:03 (GMT)
committerPeter Kümmel <syntheticpp@gmx.net>2012-07-15 20:22:27 (GMT)
commitc0c5ef9bffb0130e169aeddcb8487b670c6b56fe (patch)
tree229e624ce902d6f1cf4204c8a55a5abdee73daa6 /src/build.h
parent638b0336e98af65240c1d0d66c5e0d9e5b800d9e (diff)
downloadNinja-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/build.h')
-rw-r--r--src/build.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/build.h b/src/build.h
index c9ee4ac..4859c29 100644
--- a/src/build.h
+++ b/src/build.h
@@ -24,6 +24,7 @@
using namespace std;
#include "exit_status.h"
+#include "metrics.h"
#include "util.h" // int64_t
struct BuildLog;
@@ -191,9 +192,43 @@ struct BuildStatus {
/// The custom progress status format to use.
const char* progress_status_format_;
+ struct RateInfo {
+ RateInfo() : last_update_(0), rate_(-1) {}
+
+ double rate() const { return rate_; }
+ int last_update() const { return last_update_; }
+ void Restart() { return stopwatch_.Restart(); }
+
+ double UpdateRate(int edges, int update_hint) {
+ if (update_hint != last_update_) {
+ rate_ = edges / stopwatch_.Elapsed() + 0.5;
+ last_update_ = update_hint;
+ }
+ return rate_;
+ }
+
+ template<class T>
+ void snprinfRate(T buf, const char* format) {
+ if (rate_ == -1)
+ snprintf(buf, sizeof(buf), "?");
+ else
+ snprintf(buf, sizeof(buf), format, rate_);
+ }
+
+ private:
+ Stopwatch stopwatch_;
+ int last_update_;
+ double rate_;
+ };
+
+ mutable RateInfo overall_rate_;
+ mutable RateInfo current_rate_;
+ const int current_rate_average_count_;
+
#ifdef _WIN32
void* console_;
#endif
};
#endif // NINJA_BUILD_H_
+