[5/5] tools/lib/traceevent: Round up in tep_print_event() time precision
diff mbox series

Message ID 20190918020530.974032887@goodmis.org
State Accepted
Headers show
Series
  • trace-cmd: Update for the new trace_print_event() logic
Related show

Commit Message

Steven Rostedt Sept. 18, 2019, 2:03 a.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

When testing the output of the old trace-cmd compared to the one that uses
the updated tep_print_event() logic, it was different in that the time stamp
precision in the old format would round up to the nearest precision, where
as the new logic truncates. Bring back the old method of rounding up.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/traceevent/event-parse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Tzvetomir Stoyanov Sept. 20, 2019, 3:18 p.m. UTC | #1
On Wed, Sep 18, 2019 at 5:03 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> When testing the output of the old trace-cmd compared to the one that uses
> the updated tep_print_event() logic, it was different in that the time stamp
> precision in the old format would round up to the nearest precision, where
> as the new logic truncates. Bring back the old method of rounding up.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  lib/traceevent/event-parse.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
> index d1085aab9c43..7fbbbccab78a 100644
> --- a/lib/traceevent/event-parse.c
> +++ b/lib/traceevent/event-parse.c
> @@ -5527,8 +5527,10 @@ static void print_event_time(struct tep_handle *tep, struct trace_seq *s,
>         if (divstr && isdigit(*(divstr + 1)))
>                 div = atoi(divstr + 1);
>         time = record->ts;
> -       if (div)
> +       if (div) {
> +               time += div / 2;
>                 time /= div;
> +       }
>         pr = prec;
>         while (pr--)
>                 p10 *= 10;
> --
> 2.20.1
>
>

Looks good to me.
Reviewed-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>

Patch
diff mbox series

diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c
index d1085aab9c43..7fbbbccab78a 100644
--- a/lib/traceevent/event-parse.c
+++ b/lib/traceevent/event-parse.c
@@ -5527,8 +5527,10 @@  static void print_event_time(struct tep_handle *tep, struct trace_seq *s,
 	if (divstr && isdigit(*(divstr + 1)))
 		div = atoi(divstr + 1);
 	time = record->ts;
-	if (div)
+	if (div) {
+		time += div / 2;
 		time /= div;
+	}
 	pr = prec;
 	while (pr--)
 		p10 *= 10;