aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-16 11:31:49 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-16 12:29:10 -0500
commit9b33827de63539c7c3314ddf890fb216e4acf3d8 (patch)
tree233330d9489013a0d1c24a3920d370527b2de308 /tools
parent604c5c92972dcb4b98be34775452d09a5d4ec248 (diff)
perf diff: Percent calcs should use double values
Otherwise we do integer math and the delta values round up to multiples of 1.0%. Also, calculate absolute values. Things look precise now: $ perf report -i perf.data.old --sort dso,symbol | head -13 9.02% libc-2.10.1.so [.] _IO_vfprintf_internal 4.88% find [.] 0x00000000014af0 2.91% [kernel] [k] __kmalloc 2.85% [kernel] [k] ext4_htree_store_dirent 2.50% libc-2.10.1.so [.] __GI_memmove 2.44% [kernel] [k] half_md4_transform 2.43% [kernel] [k] _spin_lock 2.33% [kernel] [k] system_call $ perf report -i perf.data --sort dso,symbol | head -13 8.55% libc-2.10.1.so [.] _IO_vfprintf_internal 3.11% [kernel] [k] __kmalloc 3.07% [kernel] [k] ext4_htree_store_dirent 2.66% find [.] 0x00000000016bcf 2.61% [kernel] [k] _atomic_dec_and_lock 2.46% [kernel] [k] half_md4_transform 2.41% libc-2.10.1.so [.] __GI_memmove 2.30% find [.] 0x00000000009219 $ perf diff | head -13 9.02% -0.47% libc-2.10.1.so [.] _IO_vfprintf_internal 2.91% +0.20% [kernel] [k] __kmalloc 2.85% +0.23% [kernel] [k] ext4_htree_store_dirent 1.99% +0.62% [kernel] [k] _atomic_dec_and_lock 2.44% +0.02% [kernel] [k] half_md4_transform 2.50% -0.09% libc-2.10.1.so [.] __GI_memmove 1.88% +0.01% [kernel] [k] __d_lookup 2.43% -0.75% [kernel] [k] _spin_lock 0.97% +0.62% [kernel] [k] path_get 1.99% -0.42% libc-2.10.1.so [.] _int_malloc $ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1260981109-2621-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/hist.c9
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
5struct callchain_param callchain_param = { 6struct 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), " ");