Skip to content

Commit

Permalink
perf time-utils: Prevent percentage time range overlap
Browse files Browse the repository at this point in the history
Prevent percentage time range overlap. This is only a 1 nanosecond
change but makes the results more logical e.g. a sample cannot be in
both the first 10% and the second 20%.

Note, there is a later patch that adds a test for time-utils.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190604130017.31207-15-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Adrian Hunter authored and Arnaldo Carvalho de Melo committed Jun 10, 2019
1 parent c763242 commit b16bfeb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/perf/util/time-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ static int set_percent_time(struct perf_time_interval *ptime, double start_pcnt,
ptime->start = start + round(start_pcnt * total);
ptime->end = start + round(end_pcnt * total);

if (ptime->end > ptime->start && ptime->end != end)
ptime->end -= 1;

return 0;
}

Expand Down

0 comments on commit b16bfeb

Please sign in to comment.