aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2015-09-25 09:15:36 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-09-28 15:46:05 -0400
commit83e1986032dfcd3f9e9fc0d06e11d9153edae19b (patch)
tree8ad7b1b2ae0120bb8d2b39293ff4013b3f9ef9dc
parent116f349c5bf8c7aec4047dd6e06c310354b46e4f (diff)
perf script: Allow time to be displayed in nanoseconds
Add option --ns to display time to 9 decimal places. That is useful in some cases, for example when using Intel PT cycle accurate mode. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1443186956-18718-6-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-script.txt3
-rw-r--r--tools/perf/builtin-script.c8
2 files changed, 10 insertions, 1 deletions
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index dc3ec783b7bd..b3b42f9285df 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -249,6 +249,9 @@ include::itrace.txt[]
249--full-source-path:: 249--full-source-path::
250 Show the full path for source files for srcline output. 250 Show the full path for source files for srcline output.
251 251
252--ns::
253 Use 9 decimal places when displaying time (i.e. show the nanoseconds)
254
252SEE ALSO 255SEE ALSO
253-------- 256--------
254linkperf:perf-record[1], linkperf:perf-script-perl[1], 257linkperf:perf-record[1], linkperf:perf-script-perl[1],
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 284a76e04628..092843968791 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -29,6 +29,7 @@ static bool no_callchain;
29static bool latency_format; 29static bool latency_format;
30static bool system_wide; 30static bool system_wide;
31static bool print_flags; 31static bool print_flags;
32static bool nanosecs;
32static const char *cpu_list; 33static const char *cpu_list;
33static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 34static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
34 35
@@ -415,7 +416,10 @@ static void print_sample_start(struct perf_sample *sample,
415 secs = nsecs / NSECS_PER_SEC; 416 secs = nsecs / NSECS_PER_SEC;
416 nsecs -= secs * NSECS_PER_SEC; 417 nsecs -= secs * NSECS_PER_SEC;
417 usecs = nsecs / NSECS_PER_USEC; 418 usecs = nsecs / NSECS_PER_USEC;
418 printf("%5lu.%06lu: ", secs, usecs); 419 if (nanosecs)
420 printf("%5lu.%09llu: ", secs, nsecs);
421 else
422 printf("%5lu.%06lu: ", secs, usecs);
419 } 423 }
420} 424}
421 425
@@ -1695,6 +1699,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1695 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events, 1699 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
1696 "Show context switch events (if recorded)"), 1700 "Show context switch events (if recorded)"),
1697 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"), 1701 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
1702 OPT_BOOLEAN(0, "ns", &nanosecs,
1703 "Use 9 decimal places when displaying time"),
1698 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", 1704 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
1699 "Instruction Tracing options", 1705 "Instruction Tracing options",
1700 itrace_parse_synth_opts), 1706 itrace_parse_synth_opts),