diff options
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 2f93d60c5a17..61cfd8f70989 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -53,6 +53,8 @@ | |||
53 | 53 | ||
54 | static char const *script_name; | 54 | static char const *script_name; |
55 | static char const *generate_script_lang; | 55 | static char const *generate_script_lang; |
56 | static bool reltime; | ||
57 | static u64 initial_time; | ||
56 | static bool debug_mode; | 58 | static bool debug_mode; |
57 | static u64 last_timestamp; | 59 | static u64 last_timestamp; |
58 | static u64 nr_unordered; | 60 | static u64 nr_unordered; |
@@ -686,7 +688,13 @@ static int perf_sample__fprintf_start(struct perf_sample *sample, | |||
686 | } | 688 | } |
687 | 689 | ||
688 | if (PRINT_FIELD(TIME)) { | 690 | if (PRINT_FIELD(TIME)) { |
689 | nsecs = sample->time; | 691 | u64 t = sample->time; |
692 | if (reltime) { | ||
693 | if (!initial_time) | ||
694 | initial_time = sample->time; | ||
695 | t = sample->time - initial_time; | ||
696 | } | ||
697 | nsecs = t; | ||
690 | secs = nsecs / NSEC_PER_SEC; | 698 | secs = nsecs / NSEC_PER_SEC; |
691 | nsecs -= secs * NSEC_PER_SEC; | 699 | nsecs -= secs * NSEC_PER_SEC; |
692 | 700 | ||
@@ -694,7 +702,7 @@ static int perf_sample__fprintf_start(struct perf_sample *sample, | |||
694 | printed += fprintf(fp, "%5lu.%09llu: ", secs, nsecs); | 702 | printed += fprintf(fp, "%5lu.%09llu: ", secs, nsecs); |
695 | else { | 703 | else { |
696 | char sample_time[32]; | 704 | char sample_time[32]; |
697 | timestamp__scnprintf_usec(sample->time, sample_time, sizeof(sample_time)); | 705 | timestamp__scnprintf_usec(t, sample_time, sizeof(sample_time)); |
698 | printed += fprintf(fp, "%12s: ", sample_time); | 706 | printed += fprintf(fp, "%12s: ", sample_time); |
699 | } | 707 | } |
700 | } | 708 | } |
@@ -3413,6 +3421,7 @@ int cmd_script(int argc, const char **argv) | |||
3413 | "Set the maximum stack depth when parsing the callchain, " | 3421 | "Set the maximum stack depth when parsing the callchain, " |
3414 | "anything beyond the specified depth will be ignored. " | 3422 | "anything beyond the specified depth will be ignored. " |
3415 | "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)), | 3423 | "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)), |
3424 | OPT_BOOLEAN(0, "reltime", &reltime, "Show time stamps relative to start"), | ||
3416 | OPT_BOOLEAN('I', "show-info", &show_full_info, | 3425 | OPT_BOOLEAN('I', "show-info", &show_full_info, |
3417 | "display extended information from perf.data file"), | 3426 | "display extended information from perf.data file"), |
3418 | OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path, | 3427 | OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path, |
@@ -3487,6 +3496,11 @@ int cmd_script(int argc, const char **argv) | |||
3487 | } | 3496 | } |
3488 | } | 3497 | } |
3489 | 3498 | ||
3499 | if (script.time_str && reltime) { | ||
3500 | fprintf(stderr, "Don't combine --reltime with --time\n"); | ||
3501 | return -1; | ||
3502 | } | ||
3503 | |||
3490 | if (itrace_synth_opts.callchain && | 3504 | if (itrace_synth_opts.callchain && |
3491 | itrace_synth_opts.callchain_sz > scripting_max_stack) | 3505 | itrace_synth_opts.callchain_sz > scripting_max_stack) |
3492 | scripting_max_stack = itrace_synth_opts.callchain_sz; | 3506 | scripting_max_stack = itrace_synth_opts.callchain_sz; |