Skip to content

Commit 83e1986

Browse files
ahunter6acmel
authored andcommitted
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>
1 parent 116f349 commit 83e1986

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎tools/perf/Documentation/perf-script.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ include::itrace.txt[]
249249
--full-source-path::
250250
Show the full path for source files for srcline output.
251251

252+
--ns::
253+
Use 9 decimal places when displaying time (i.e. show the nanoseconds)
254+
252255
SEE ALSO
253256
--------
254257
linkperf:perf-record[1], linkperf:perf-script-perl[1],

‎tools/perf/builtin-script.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static bool no_callchain;
2929
static bool latency_format;
3030
static bool system_wide;
3131
static bool print_flags;
32+
static bool nanosecs;
3233
static const char *cpu_list;
3334
static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
3435

@@ -415,7 +416,10 @@ static void print_sample_start(struct perf_sample *sample,
415416
secs = nsecs / NSECS_PER_SEC;
416417
nsecs -= secs * NSECS_PER_SEC;
417418
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);
419423
}
420424
}
421425

@@ -1695,6 +1699,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
16951699
OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
16961700
"Show context switch events (if recorded)"),
16971701
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"),
16981704
OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
16991705
"Instruction Tracing options",
17001706
itrace_parse_synth_opts),

0 commit comments

Comments
 (0)