|
53 | 53 |
|
54 | 54 | static char const *script_name;
|
55 | 55 | static char const *generate_script_lang;
|
| 56 | +static bool reltime; |
| 57 | +static u64 initial_time; |
56 | 58 | static bool debug_mode;
|
57 | 59 | static u64 last_timestamp;
|
58 | 60 | static u64 nr_unordered;
|
@@ -686,15 +688,21 @@ static int perf_sample__fprintf_start(struct perf_sample *sample,
|
686 | 688 | }
|
687 | 689 |
|
688 | 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 | 698 | secs = nsecs / NSEC_PER_SEC;
|
691 | 699 | nsecs -= secs * NSEC_PER_SEC;
|
692 | 700 |
|
693 | 701 | if (symbol_conf.nanosecs)
|
694 | 702 | printed += fprintf(fp, "%5lu.%09llu: ", secs, nsecs);
|
695 | 703 | else {
|
696 | 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 | 706 | printed += fprintf(fp, "%12s: ", sample_time);
|
699 | 707 | }
|
700 | 708 | }
|
@@ -3413,6 +3421,7 @@ int cmd_script(int argc, const char **argv)
|
3413 | 3421 | "Set the maximum stack depth when parsing the callchain, "
|
3414 | 3422 | "anything beyond the specified depth will be ignored. "
|
3415 | 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 | 3425 | OPT_BOOLEAN('I', "show-info", &show_full_info,
|
3417 | 3426 | "display extended information from perf.data file"),
|
3418 | 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 | 3504 | if (itrace_synth_opts.callchain &&
|
3491 | 3505 | itrace_synth_opts.callchain_sz > scripting_max_stack)
|
3492 | 3506 | scripting_max_stack = itrace_synth_opts.callchain_sz;
|
|
0 commit comments