diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/hist.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index ecf853cdc0bf..e8daf5ca6fd2 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "hist.h" | 1 | #include "hist.h" |
2 | #include "session.h" | 2 | #include "session.h" |
3 | #include "sort.h" | 3 | #include "sort.h" |
4 | #include <math.h> | ||
4 | 5 | ||
5 | struct callchain_param callchain_param = { | 6 | struct callchain_param callchain_param = { |
6 | .mode = CHAIN_GRAPH_REL, | 7 | .mode = CHAIN_GRAPH_REL, |
@@ -494,13 +495,13 @@ static size_t hist_entry__fprintf(struct hist_entry *self, | |||
494 | double old_percent = 0, new_percent = 0, diff; | 495 | double old_percent = 0, new_percent = 0, diff; |
495 | 496 | ||
496 | if (total > 0) | 497 | if (total > 0) |
497 | old_percent = (count * 100) / total; | 498 | old_percent = (count * 100.0) / total; |
498 | if (session->events_stats.total > 0) | 499 | if (session->events_stats.total > 0) |
499 | new_percent = (self->count * 100) / session->events_stats.total; | 500 | new_percent = (self->count * 100.0) / session->events_stats.total; |
500 | 501 | ||
501 | diff = old_percent - new_percent; | 502 | diff = new_percent - old_percent; |
502 | 503 | ||
503 | if ((u64)diff != 0) | 504 | if (fabs(diff) >= 0.01) |
504 | snprintf(bf, sizeof(bf), "%+4.2F%%", diff); | 505 | snprintf(bf, sizeof(bf), "%+4.2F%%", diff); |
505 | else | 506 | else |
506 | snprintf(bf, sizeof(bf), " "); | 507 | snprintf(bf, sizeof(bf), " "); |