Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
83e19860 116f349c

+10 -1
+3
tools/perf/Documentation/perf-script.txt
··· 249 249 --full-source-path:: 250 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 + 252 255 SEE ALSO 253 256 -------- 254 257 linkperf:perf-record[1], linkperf:perf-script-perl[1],
+7 -1
tools/perf/builtin-script.c
··· 29 29 static bool latency_format; 30 30 static bool system_wide; 31 31 static bool print_flags; 32 + static bool nanosecs; 32 33 static const char *cpu_list; 33 34 static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); 34 35 ··· 416 415 secs = nsecs / NSECS_PER_SEC; 417 416 nsecs -= secs * NSECS_PER_SEC; 418 417 usecs = nsecs / NSECS_PER_USEC; 419 - printf("%5lu.%06lu: ", secs, usecs); 418 + if (nanosecs) 419 + printf("%5lu.%09llu: ", secs, nsecs); 420 + else 421 + printf("%5lu.%06lu: ", secs, usecs); 420 422 } 421 423 } 422 424 ··· 1699 1695 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events, 1700 1696 "Show context switch events (if recorded)"), 1701 1697 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"), 1698 + OPT_BOOLEAN(0, "ns", &nanosecs, 1699 + "Use 9 decimal places when displaying time"), 1702 1700 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", 1703 1701 "Instruction Tracing options", 1704 1702 itrace_parse_synth_opts),