summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-01-06 18:07:45 (GMT)
committerEvan Martin <martine@danga.com>2012-01-06 20:52:17 (GMT)
commitd9373ff17c49cb5d913d38ef0ed3efa8a11ca6df (patch)
treec5524afa9a1b4076d14c016eb235c6a5fbca8082
parent12bf7b273f0675fae51601cbba2db259030fe173 (diff)
downloadNinja-d9373ff17c49cb5d913d38ef0ed3efa8a11ca6df.zip
Ninja-d9373ff17c49cb5d913d38ef0ed3efa8a11ca6df.tar.gz
Ninja-d9373ff17c49cb5d913d38ef0ed3efa8a11ca6df.tar.bz2
dynamic metrics report width
-rw-r--r--src/metrics.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/metrics.cc b/src/metrics.cc
index 07caade..1c7b7de 100644
--- a/src/metrics.cc
+++ b/src/metrics.cc
@@ -96,13 +96,20 @@ Metric* Metrics::NewMetric(const string& name) {
}
void Metrics::Report() {
- printf("%-10s\t%-6s\t%9s\t%s\n",
+ int width = 0;
+ for (vector<Metric*>::iterator i = metrics_.begin();
+ i != metrics_.end(); ++i) {
+ width = max((int)(*i)->name.size(), width);
+ }
+
+ printf("%-*s\t%-6s\t%9s\t%s\n", width,
"metric", "count", "total (ms)" , "avg (us)");
- for (vector<Metric*>::iterator i = metrics_.begin(); i != metrics_.end(); ++i) {
+ for (vector<Metric*>::iterator i = metrics_.begin();
+ i != metrics_.end(); ++i) {
Metric* metric = *i;
double total = metric->sum / (double)1000;
double avg = metric->sum / (double)metric->count;
- printf("%-10s\t%-6d\t%-8.1f\t%.1f\n", metric->name.c_str(),
+ printf("%-*s\t%-6d\t%-8.1f\t%.1f\n", width, metric->name.c_str(),
metric->count, total, avg);
}
}