Source
46
46
#include <sys/types.h>
47
47
#include <sys/stat.h>
48
48
#include <fcntl.h>
49
49
#include <unistd.h>
50
50
#include <subcmd/pager.h>
51
51
52
52
#include "sane_ctype.h"
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;
59
61
static bool no_callchain;
60
62
static bool latency_format;
61
63
static bool system_wide;
62
64
static bool print_flags;
63
65
static const char *cpu_list;
64
66
static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
65
67
static struct perf_stat_config stat_config;
679
681
break;
680
682
}
681
683
682
684
#undef has
683
685
684
686
ret += fprintf(fp, "%*s", 6 - ret, " ");
685
687
printed += ret;
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
}
701
709
702
710
return printed;
703
711
}
704
712
705
713
static inline char
706
714
mispred_str(struct branch_entry *br)
707
715
{
3406
3414
OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
3407
3415
"only display events for these comms"),
3408
3416
OPT_STRING(0, "pid", &symbol_conf.pid_list_str, "pid[,pid...]",
3409
3417
"only consider symbols in these pids"),
3410
3418
OPT_STRING(0, "tid", &symbol_conf.tid_list_str, "tid[,tid...]",
3411
3419
"only consider symbols in these tids"),
3412
3420
OPT_UINTEGER(0, "max-stack", &scripting_max_stack,
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,
3419
3428
"Show the path of [kernel.kallsyms]"),
3420
3429
OPT_BOOLEAN('\0', "show-task-events", &script.show_task_events,
3421
3430
"Show the fork/comm/exit events"),
3422
3431
OPT_BOOLEAN('\0', "show-mmap-events", &script.show_mmap_events,
3423
3432
"Show the mmap events"),
3424
3433
OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
3425
3434
"Show context switch events (if recorded)"),
3480
3489
if (argc > 1 && !strncmp(argv[0], "rep", strlen("rep"))) {
3481
3490
rep_script_path = get_script_path(argv[1], REPORT_SUFFIX);
3482
3491
if (!rep_script_path) {
3483
3492
fprintf(stderr,
3484
3493
"Please specify a valid report script"
3485
3494
"(see 'perf script -l' for listing)\n");
3486
3495
return -1;
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;
3493
3507
3494
3508
/* make sure PERF_EXEC_PATH is set for scripts */
3495
3509
set_argv_exec_path(get_argv_exec_path());
3496
3510
3497
3511
if (argc && !script_name && !rec_script_path && !rep_script_path) {
3498
3512
int live_pipe[2];
3499
3513
int rep_args;