Permalink
Browse files

factor out metrics dump from ninja main

  • Loading branch information...
1 parent c84ee51 commit 14863bbc3337a64099f8509daf407f8ec1570c38 @evmar evmar committed Sep 5, 2012
Showing with 18 additions and 14 deletions.
  1. +18 −14 src/ninja.cc
View
32 src/ninja.cc
@@ -609,6 +609,22 @@ bool OpenLog(BuildLog* build_log, Globals* globals,
return true;
}
+/// Dump the output requested by '-d stats'.
+void DumpMetrics(Globals* globals) {
+ g_metrics->Report();
+
+ printf("\n");
+ int count = (int)globals->state->paths_.size();
+ int buckets =
+#ifdef _MSC_VER
+ (int)globals->state->paths_.comp.bucket_size;
+#else
+ (int)globals->state->paths_.bucket_count();
+#endif
+ printf("path->node hash load %.2f (%d entries / %d buckets)\n",
+ count / (double) buckets, count, buckets);
+}
+
int RunBuild(Builder* builder, int argc, char** argv) {
string err;
vector<Node*> targets;
@@ -811,20 +827,8 @@ int NinjaMain(int argc, char** argv) {
Builder builder(globals.state, config, &build_log, &disk_interface);
int result = RunBuild(&builder, argc, argv);
- if (g_metrics) {
- g_metrics->Report();
-
- printf("\n");
- int count = (int)globals.state->paths_.size();
- int buckets =
-#ifdef _MSC_VER
- (int)globals.state->paths_.comp.bucket_size;
-#else
- (int)globals.state->paths_.bucket_count();
-#endif
- printf("path->node hash load %.2f (%d entries / %d buckets)\n",
- count / (double) buckets, count, buckets);
- }
+ if (g_metrics)
+ DumpMetrics(&globals);
return result;
}

0 comments on commit 14863bb

Please sign in to comment.