diff options
author | Andi Kleen <ak@linux.intel.com> | 2015-03-11 10:16:27 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-13 06:46:04 -0400 |
commit | d73515c03c6a2706e088094ff6095a3abefd398b (patch) | |
tree | 28621ab991a9313942827ab79e2de28967a18a66 /tools | |
parent | 4fabf3d19cec11d9faa567f8cf0290298c5a93ea (diff) |
perf stat: Output running time and run/enabled ratio in CSV mode
The information how much a counter ran in 'perf stat' can be quite
interesting for other tools to judge how trustworthy a measurement is.
Currently it is only output in non CSV mode.
This patches make perf stat always output the running time and the
enabled/running ratio in CSV mode.
This adds two new fields at the end for each line. I assume that
existing tools ignore new fields at the end, so it's on by default.
Only CSV mode is affected, no difference otherwise.
v2: Add extra print_running function
v3: Avoid printing nan
v4: Remove some elses and add brackets.
v5: Move non CSV case into print_running
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Reviewed-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1426083387-17006-1-git-send-email-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-stat.c | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d28949d210cc..d58e50cbc6ec 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -769,6 +769,19 @@ static int run_perf_stat(int argc, const char **argv) | |||
769 | return ret; | 769 | return ret; |
770 | } | 770 | } |
771 | 771 | ||
772 | static void print_running(u64 run, u64 ena) | ||
773 | { | ||
774 | if (csv_output) { | ||
775 | fprintf(output, "%s%" PRIu64 "%s%.2f", | ||
776 | csv_sep, | ||
777 | run, | ||
778 | csv_sep, | ||
779 | ena ? 100.0 * run / ena : 100.0); | ||
780 | } else if (run != ena) { | ||
781 | fprintf(output, " (%.2f%%)", 100.0 * run / ena); | ||
782 | } | ||
783 | } | ||
784 | |||
772 | static void print_noise_pct(double total, double avg) | 785 | static void print_noise_pct(double total, double avg) |
773 | { | 786 | { |
774 | double pct = rel_stddev_stats(total, avg); | 787 | double pct = rel_stddev_stats(total, avg); |
@@ -1252,6 +1265,7 @@ static void print_aggr(char *prefix) | |||
1252 | fprintf(output, "%s%s", | 1265 | fprintf(output, "%s%s", |
1253 | csv_sep, counter->cgrp->name); | 1266 | csv_sep, counter->cgrp->name); |
1254 | 1267 | ||
1268 | print_running(run, ena); | ||
1255 | fputc('\n', output); | 1269 | fputc('\n', output); |
1256 | continue; | 1270 | continue; |
1257 | } | 1271 | } |
@@ -1262,13 +1276,10 @@ static void print_aggr(char *prefix) | |||
1262 | else | 1276 | else |
1263 | abs_printout(id, nr, counter, uval); | 1277 | abs_printout(id, nr, counter, uval); |
1264 | 1278 | ||
1265 | if (!csv_output) { | 1279 | if (!csv_output) |
1266 | print_noise(counter, 1.0); | 1280 | print_noise(counter, 1.0); |
1267 | 1281 | ||
1268 | if (run != ena) | 1282 | print_running(run, ena); |
1269 | fprintf(output, " (%.2f%%)", | ||
1270 | 100.0 * run / ena); | ||
1271 | } | ||
1272 | fputc('\n', output); | 1283 | fputc('\n', output); |
1273 | } | 1284 | } |
1274 | } | 1285 | } |
@@ -1284,6 +1295,10 @@ static void print_counter_aggr(struct perf_evsel *counter, char *prefix) | |||
1284 | double avg = avg_stats(&ps->res_stats[0]); | 1295 | double avg = avg_stats(&ps->res_stats[0]); |
1285 | int scaled = counter->counts->scaled; | 1296 | int scaled = counter->counts->scaled; |
1286 | double uval; | 1297 | double uval; |
1298 | double avg_enabled, avg_running; | ||
1299 | |||
1300 | avg_enabled = avg_stats(&ps->res_stats[1]); | ||
1301 | avg_running = avg_stats(&ps->res_stats[2]); | ||
1287 | 1302 | ||
1288 | if (prefix) | 1303 | if (prefix) |
1289 | fprintf(output, "%s", prefix); | 1304 | fprintf(output, "%s", prefix); |
@@ -1303,6 +1318,7 @@ static void print_counter_aggr(struct perf_evsel *counter, char *prefix) | |||
1303 | if (counter->cgrp) | 1318 | if (counter->cgrp) |
1304 | fprintf(output, "%s%s", csv_sep, counter->cgrp->name); | 1319 | fprintf(output, "%s%s", csv_sep, counter->cgrp->name); |
1305 | 1320 | ||
1321 | print_running(avg_running, avg_enabled); | ||
1306 | fputc('\n', output); | 1322 | fputc('\n', output); |
1307 | return; | 1323 | return; |
1308 | } | 1324 | } |
@@ -1316,19 +1332,7 @@ static void print_counter_aggr(struct perf_evsel *counter, char *prefix) | |||
1316 | 1332 | ||
1317 | print_noise(counter, avg); | 1333 | print_noise(counter, avg); |
1318 | 1334 | ||
1319 | if (csv_output) { | 1335 | print_running(avg_running, avg_enabled); |
1320 | fputc('\n', output); | ||
1321 | return; | ||
1322 | } | ||
1323 | |||
1324 | if (scaled) { | ||
1325 | double avg_enabled, avg_running; | ||
1326 | |||
1327 | avg_enabled = avg_stats(&ps->res_stats[1]); | ||
1328 | avg_running = avg_stats(&ps->res_stats[2]); | ||
1329 | |||
1330 | fprintf(output, " [%5.2f%%]", 100 * avg_running / avg_enabled); | ||
1331 | } | ||
1332 | fprintf(output, "\n"); | 1336 | fprintf(output, "\n"); |
1333 | } | 1337 | } |
1334 | 1338 | ||
@@ -1370,6 +1374,7 @@ static void print_counter(struct perf_evsel *counter, char *prefix) | |||
1370 | fprintf(output, "%s%s", | 1374 | fprintf(output, "%s%s", |
1371 | csv_sep, counter->cgrp->name); | 1375 | csv_sep, counter->cgrp->name); |
1372 | 1376 | ||
1377 | print_running(run, ena); | ||
1373 | fputc('\n', output); | 1378 | fputc('\n', output); |
1374 | continue; | 1379 | continue; |
1375 | } | 1380 | } |
@@ -1381,13 +1386,10 @@ static void print_counter(struct perf_evsel *counter, char *prefix) | |||
1381 | else | 1386 | else |
1382 | abs_printout(cpu, 0, counter, uval); | 1387 | abs_printout(cpu, 0, counter, uval); |
1383 | 1388 | ||
1384 | if (!csv_output) { | 1389 | if (!csv_output) |
1385 | print_noise(counter, 1.0); | 1390 | print_noise(counter, 1.0); |
1391 | print_running(run, ena); | ||
1386 | 1392 | ||
1387 | if (run != ena) | ||
1388 | fprintf(output, " (%.2f%%)", | ||
1389 | 100.0 * run / ena); | ||
1390 | } | ||
1391 | fputc('\n', output); | 1393 | fputc('\n', output); |
1392 | } | 1394 | } |
1393 | } | 1395 | } |