summaryrefslogtreecommitdiffstats
path: root/src/build.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-05-09 23:24:24 (GMT)
committerEvan Martin <martine@danga.com>2011-05-11 18:29:01 (GMT)
commitfa8830b546428e1daa829d0ddf2465697e0d9bb3 (patch)
treee824209be8b0276109ae419ef024e28b59ec35bd /src/build.cc
parent3f7f99fbb5b064f2850543cf5574a6dc2b8d3a9d (diff)
downloadNinja-fa8830b546428e1daa829d0ddf2465697e0d9bb3.zip
Ninja-fa8830b546428e1daa829d0ddf2465697e0d9bb3.tar.gz
Ninja-fa8830b546428e1daa829d0ddf2465697e0d9bb3.tar.bz2
add a versioning header to build log, switch to v2
In v2 we store both the start and end time of the command. This allows better visualization of the build process.
Diffstat (limited to 'src/build.cc')
-rw-r--r--src/build.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/build.cc b/src/build.cc
index 7f7ae6d..1deb08a 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -49,15 +49,19 @@ struct BuildStatus {
BuildStatus();
void PlanHasTotalEdges(int total);
void BuildEdgeStarted(Edge* edge);
- /// Returns the time the edge took, in ms.
- int BuildEdgeFinished(Edge* edge);
+ void BuildEdgeFinished(Edge* edge, int* start_time, int* end_time);
void PrintStatus(Edge* edge);
+ /// Time the build started.
+ int64_t start_time_millis_;
+ /// Time we last printed an update.
int64_t last_update_millis_;
+
int finished_edges_, total_edges_;
- typedef map<Edge*, int64_t> RunningEdgeMap;
+ /// Map of running edge to time the edge started running.
+ typedef map<Edge*, int> RunningEdgeMap;
RunningEdgeMap running_edges_;
BuildConfig::Verbosity verbosity_;
@@ -66,7 +70,8 @@ struct BuildStatus {
};
BuildStatus::BuildStatus()
- : last_update_millis_(GetTimeMillis()),
+ : start_time_millis_(GetTimeMillis()),
+ last_update_millis_(start_time_millis_),
finished_edges_(0), total_edges_(0),
verbosity_(BuildConfig::NORMAL) {
#ifndef WIN32
@@ -82,12 +87,15 @@ void BuildStatus::PlanHasTotalEdges(int total) {
}
void BuildStatus::BuildEdgeStarted(Edge* edge) {
- running_edges_.insert(make_pair(edge, GetTimeMillis()));
+ int start_time = (int)(GetTimeMillis() - start_time_millis_);
+ running_edges_.insert(make_pair(edge, start_time));
PrintStatus(edge);
}
-int BuildStatus::BuildEdgeFinished(Edge* edge) {
+void BuildStatus::BuildEdgeFinished(Edge* edge,
+ int* start_time,
+ int* end_time) {
int64_t now = GetTimeMillis();
++finished_edges_;
@@ -106,10 +114,9 @@ int BuildStatus::BuildEdgeFinished(Edge* edge) {
}
RunningEdgeMap::iterator i = running_edges_.find(edge);
- int ms = (int)(now - i->second);
+ *start_time = i->second;
+ *end_time = (int)(now - start_time_millis_);
running_edges_.erase(i);
-
- return ms;
}
void BuildStatus::PrintStatus(Edge* edge) {
@@ -487,7 +494,8 @@ void Builder::FinishEdge(Edge* edge) {
if (edge->is_phony())
return;
- int ms = status_->BuildEdgeFinished(edge);
+ int start_time, end_time;
+ status_->BuildEdgeFinished(edge, &start_time, &end_time);
if (log_)
- log_->RecordCommand(edge, ms);
+ log_->RecordCommand(edge, start_time, end_time);
}