]> Pileus Git - ~andy/linux/blobdiff - tools/perf/bench/sched-pipe.c
perf bench: Add "all" pseudo subsystem and "all" pseudo suite
[~andy/linux] / tools / perf / bench / sched-pipe.c
index 6a29100e9282715b1948ac9432b7fe6ef16f3aa0..2354f3830b1e264c6f85e9a4e96305b5fd0618ee 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * builtin-bench-pipe.c
+ * sched-pipe.c
  *
  * pipe: Benchmark for pipe()
  *
 
 #define LOOPS_DEFAULT 1000000
 static int loops = LOOPS_DEFAULT;
-static int simple = 0;
 
 static const struct option options[] = {
        OPT_INTEGER('l', "loop", &loops,
                    "Specify number of loops"),
-       OPT_BOOLEAN('s', "simple-output", &simple,
-                   "Do simple output (this maybe useful for"
-                   "processing by scripts or graph tools like gnuplot)"),
        OPT_END()
 };
 
@@ -91,26 +87,38 @@ int bench_sched_pipe(int argc, const char **argv,
        if (pid) {
                retpid = waitpid(pid, &wait_stat, 0);
                assert((retpid == pid) && WIFEXITED(wait_stat));
-               return 0;
+       } else {
+               exit(0);
        }
 
-       if (simple)
-               printf("%lu.%03lu\n",
-                      diff.tv_sec, diff.tv_usec / 1000);
-       else {
-               printf("(executing %d pipe operations between two tasks)\n\n",
+       switch (bench_format) {
+       case BENCH_FORMAT_DEFAULT:
+               printf("# Extecuted %d pipe operations between two tasks\n\n",
                        loops);
 
                result_usec = diff.tv_sec * 1000000;
                result_usec += diff.tv_usec;
 
-               printf("\tTotal time:%lu.%03lu sec\n",
-                      diff.tv_sec, diff.tv_usec / 1000);
-               printf("\t\t%lf usecs/op\n",
+               printf(" %14s: %lu.%03lu [sec]\n\n", "Total time",
+                      diff.tv_sec, diff.tv_usec/1000);
+
+               printf(" %14lf usecs/op\n",
                       (double)result_usec / (double)loops);
-               printf("\t\t%d ops/sec\n",
+               printf(" %14d ops/sec\n",
                       (int)((double)loops /
                             ((double)result_usec / (double)1000000)));
+               break;
+
+       case BENCH_FORMAT_SIMPLE:
+               printf("%lu.%03lu\n",
+                      diff.tv_sec, diff.tv_usec / 1000);
+               break;
+
+       default:
+               /* reaching here is something disaster */
+               fprintf(stderr, "Unknown format:%d\n", bench_format);
+               exit(1);
+               break;
        }
 
        return 0;