summaryrefslogtreecommitdiffstats
path: root/src/build.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/build.h')
-rw-r--r--src/build.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/build.h b/src/build.h
index c9ee4ac..5e26bbb 100644
--- a/src/build.h
+++ b/src/build.h
@@ -21,9 +21,10 @@
#include <queue>
#include <vector>
#include <memory>
-using namespace std;
+#include <cstdio>
#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_
+