]> Git Repo - linux.git/blobdiff - tools/perf/builtin-script.c
perf script: Allow time to be displayed in nanoseconds
[linux.git] / tools / perf / builtin-script.c
index 284a76e046284983cd769da89cb45604b114a41a..0928439687911f9ae76bf9985d570f7e4b561b0a 100644 (file)
@@ -29,6 +29,7 @@ static bool                   no_callchain;
 static bool                    latency_format;
 static bool                    system_wide;
 static bool                    print_flags;
+static bool                    nanosecs;
 static const char              *cpu_list;
 static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 
@@ -415,7 +416,10 @@ static void print_sample_start(struct perf_sample *sample,
                secs = nsecs / NSECS_PER_SEC;
                nsecs -= secs * NSECS_PER_SEC;
                usecs = nsecs / NSECS_PER_USEC;
-               printf("%5lu.%06lu: ", secs, usecs);
+               if (nanosecs)
+                       printf("%5lu.%09llu: ", secs, nsecs);
+               else
+                       printf("%5lu.%06lu: ", secs, usecs);
        }
 }
 
@@ -1695,6 +1699,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
        OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
                    "Show context switch events (if recorded)"),
        OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
+       OPT_BOOLEAN(0, "ns", &nanosecs,
+                   "Use 9 decimal places when displaying time"),
        OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
                            "Instruction Tracing options",
                            itrace_parse_synth_opts),
This page took 0.036169 seconds and 4 git commands to generate.