diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2016-03-01 17:22:32 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2016-03-01 17:24:33 -0500 |
commit | c21aae2c80718d4820a61a96aaa1533d358f1b1c (patch) | |
tree | 1d9b14ff4bd5b1a84d70b0154fc6fe70b7b010b3 | |
parent | 8533bda27f64d2b72d95c1fb585f5310f7253106 (diff) | |
download | trace-cmd-c21aae2c80718d4820a61a96aaa1533d358f1b1c.tar.gz |
trace-cmd report: Add --ts-diff to show the delta between timestamps
If --ts-diff is added to trace-cmd report, it will show the delta between
events. It doesn't matter which CPUs they are on. In case of filtering, the
delta is still only between the visible events.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | Documentation/trace-cmd-report.1.txt | 4 | ||||
-rw-r--r-- | trace-read.c | 34 | ||||
-rw-r--r-- | trace-usage.c | 1 |
3 files changed, 37 insertions, 2 deletions
diff --git a/Documentation/trace-cmd-report.1.txt b/Documentation/trace-cmd-report.1.txt index c969694c..20d6b7ab 100644 --- a/Documentation/trace-cmd-report.1.txt +++ b/Documentation/trace-cmd-report.1.txt @@ -286,6 +286,10 @@ OPTIONS The value of --ts-offset must still be in the raw timestamp units, even with this option. The offset will be converted as well. +*--ts-diff*:: + Show the time differences between events. The difference will appear in + parenthesis just after the timestamp. + EXAMPLES -------- diff --git a/trace-read.c b/trace-read.c index bd7e56d0..79519bd6 100644 --- a/trace-read.c +++ b/trace-read.c @@ -112,6 +112,8 @@ static int debug = 0; static int no_irqs; static int no_softirqs; +static int tsdiff; + static struct format_field *wakeup_task; static struct format_field *wakeup_success; static struct format_field *wakeup_new_task; @@ -767,6 +769,9 @@ void trace_show_data(struct tracecmd_input *handle, struct pevent_record *record struct trace_seq s; int cpu = record->cpu; bool use_trace_clock; + static unsigned long long last_ts; + unsigned long long diff_ts; + char buf[50]; pevent = tracecmd_get_pevent(handle); @@ -793,7 +798,27 @@ void trace_show_data(struct tracecmd_input *handle, struct pevent_record *record } } use_trace_clock = tracecmd_get_use_trace_clock(handle); - pevent_print_event(pevent, &s, record, use_trace_clock); + if (tsdiff) { + struct event_format *event; + unsigned long long rec_ts = record->ts; + + event = pevent_find_event_by_record(pevent, record); + pevent_print_event_task(pevent, &s, event, record); + pevent_print_event_time(pevent, &s, event, record, + use_trace_clock); + buf[0] = 0; + if (use_trace_clock && !(pevent->flags & PEVENT_NSEC_OUTPUT)) + rec_ts = (rec_ts + 500) / 1000; + if (last_ts) { + diff_ts = rec_ts - last_ts; + snprintf(buf, 50, "(+%lld)", diff_ts); + buf[49] = 0; + } + last_ts = rec_ts; + trace_seq_printf(&s, " %-8s", buf); + pevent_print_event_data(pevent, &s, event, record); + } else + pevent_print_event(pevent, &s, record, use_trace_clock); if (s.len && *(s.buffer + s.len - 1) == '\n') s.len--; if (debug) { @@ -834,7 +859,7 @@ void trace_show_data(struct tracecmd_input *handle, struct pevent_record *record } } } - + trace_seq_do_printf(&s); trace_seq_destroy(&s); @@ -1364,6 +1389,7 @@ static void add_hook(const char *arg) } enum { + OPT_tsdiff = 239, OPT_ts2secs = 240, OPT_tsoffset = 241, OPT_bycomm = 242, @@ -1449,6 +1475,7 @@ void trace_report (int argc, char **argv) {"by-comm", no_argument, NULL, OPT_bycomm}, {"ts-offset", required_argument, NULL, OPT_tsoffset}, {"ts2secs", required_argument, NULL, OPT_ts2secs}, + {"ts-diff", no_argument, NULL, OPT_tsdiff}, {"help", no_argument, NULL, '?'}, {NULL, 0, NULL, 0} }; @@ -1612,6 +1639,9 @@ void trace_report (int argc, char **argv) if (!input_file) die("--ts-offset must come after -i"); break; + case OPT_tsdiff: + tsdiff = 1; + break; default: usage(argv); } diff --git a/trace-usage.c b/trace-usage.c index af57ea16..b5304ef9 100644 --- a/trace-usage.c +++ b/trace-usage.c @@ -167,6 +167,7 @@ static struct usage_help usage_help[] = { " to convert the displayed timestamps to seconds\n" " Affects the previous data file, unless there was no\n" " previous data file, in which case it becomes default\n" + " --ts-diff Show the delta timestamp between events.\n" }, { "stream", |