aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-10-21 17:31:51 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-07-12 12:54:14 -0400
commitef358e6dcaba76d1c00dba5fc6cd4cde1d1a2f13 (patch)
treef069f469b9706bc9e3b3f6b70ac11badbcbe6ac4 /tools/perf
parent3a3beae81dae4960cac99fb6deeaca371f0790eb (diff)
perf diff: Making compute functions static
All compute functions are now local to the diff command, making them static. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/n/tip-mpmm8l71mnlp7139voba3aak@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-diff.c30
-rw-r--r--tools/perf/util/hist.h7
2 files changed, 15 insertions, 22 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index cc7bf4faacd4..f2fbf69ad984 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -224,23 +224,23 @@ static int setup_compute(const struct option *opt, const char *str,
224 return -EINVAL; 224 return -EINVAL;
225} 225}
226 226
227double perf_diff__period_percent(struct hist_entry *he, u64 period) 227static double period_percent(struct hist_entry *he, u64 period)
228{ 228{
229 u64 total = he->hists->stats.total_period; 229 u64 total = he->hists->stats.total_period;
230 return (period * 100.0) / total; 230 return (period * 100.0) / total;
231} 231}
232 232
233double perf_diff__compute_delta(struct hist_entry *he, struct hist_entry *pair) 233static double compute_delta(struct hist_entry *he, struct hist_entry *pair)
234{ 234{
235 double old_percent = perf_diff__period_percent(he, he->stat.period); 235 double old_percent = period_percent(he, he->stat.period);
236 double new_percent = perf_diff__period_percent(pair, pair->stat.period); 236 double new_percent = period_percent(pair, pair->stat.period);
237 237
238 pair->diff.period_ratio_delta = new_percent - old_percent; 238 pair->diff.period_ratio_delta = new_percent - old_percent;
239 pair->diff.computed = true; 239 pair->diff.computed = true;
240 return pair->diff.period_ratio_delta; 240 return pair->diff.period_ratio_delta;
241} 241}
242 242
243double perf_diff__compute_ratio(struct hist_entry *he, struct hist_entry *pair) 243static double compute_ratio(struct hist_entry *he, struct hist_entry *pair)
244{ 244{
245 double old_period = he->stat.period ?: 1; 245 double old_period = he->stat.period ?: 1;
246 double new_period = pair->stat.period; 246 double new_period = pair->stat.period;
@@ -250,7 +250,7 @@ double perf_diff__compute_ratio(struct hist_entry *he, struct hist_entry *pair)
250 return pair->diff.period_ratio; 250 return pair->diff.period_ratio;
251} 251}
252 252
253s64 perf_diff__compute_wdiff(struct hist_entry *he, struct hist_entry *pair) 253static s64 compute_wdiff(struct hist_entry *he, struct hist_entry *pair)
254{ 254{
255 u64 old_period = he->stat.period; 255 u64 old_period = he->stat.period;
256 u64 new_period = pair->stat.period; 256 u64 new_period = pair->stat.period;
@@ -292,8 +292,8 @@ static int formula_wdiff(struct hist_entry *he, struct hist_entry *pair,
292 new_period, compute_wdiff_w2, old_period, compute_wdiff_w1); 292 new_period, compute_wdiff_w2, old_period, compute_wdiff_w1);
293} 293}
294 294
295int perf_diff__formula(struct hist_entry *he, struct hist_entry *pair, 295static int formula_fprintf(struct hist_entry *he, struct hist_entry *pair,
296 char *buf, size_t size) 296 char *buf, size_t size)
297{ 297{
298 switch (compute) { 298 switch (compute) {
299 case COMPUTE_DELTA: 299 case COMPUTE_DELTA:
@@ -421,13 +421,13 @@ static void hists__precompute(struct hists *hists)
421 421
422 switch (compute) { 422 switch (compute) {
423 case COMPUTE_DELTA: 423 case COMPUTE_DELTA:
424 perf_diff__compute_delta(he, pair); 424 compute_delta(he, pair);
425 break; 425 break;
426 case COMPUTE_RATIO: 426 case COMPUTE_RATIO:
427 perf_diff__compute_ratio(he, pair); 427 compute_ratio(he, pair);
428 break; 428 break;
429 case COMPUTE_WEIGHTED_DIFF: 429 case COMPUTE_WEIGHTED_DIFF:
430 perf_diff__compute_wdiff(he, pair); 430 compute_wdiff(he, pair);
431 break; 431 break;
432 default: 432 default:
433 BUG_ON(1); 433 BUG_ON(1);
@@ -744,7 +744,7 @@ hpp__entry_pair(struct hist_entry *he, struct hist_entry *pair,
744 if (pair->diff.computed) 744 if (pair->diff.computed)
745 diff = pair->diff.period_ratio_delta; 745 diff = pair->diff.period_ratio_delta;
746 else 746 else
747 diff = perf_diff__compute_delta(he, pair); 747 diff = compute_delta(he, pair);
748 748
749 if (fabs(diff) >= 0.01) 749 if (fabs(diff) >= 0.01)
750 scnprintf(buf, size, "%+4.2F%%", diff); 750 scnprintf(buf, size, "%+4.2F%%", diff);
@@ -758,7 +758,7 @@ hpp__entry_pair(struct hist_entry *he, struct hist_entry *pair,
758 if (pair->diff.computed) 758 if (pair->diff.computed)
759 ratio = pair->diff.period_ratio; 759 ratio = pair->diff.period_ratio;
760 else 760 else
761 ratio = perf_diff__compute_ratio(he, pair); 761 ratio = compute_ratio(he, pair);
762 762
763 if (ratio > 0.0) 763 if (ratio > 0.0)
764 scnprintf(buf, size, "%14.6F", ratio); 764 scnprintf(buf, size, "%14.6F", ratio);
@@ -772,14 +772,14 @@ hpp__entry_pair(struct hist_entry *he, struct hist_entry *pair,
772 if (pair->diff.computed) 772 if (pair->diff.computed)
773 wdiff = pair->diff.wdiff; 773 wdiff = pair->diff.wdiff;
774 else 774 else
775 wdiff = perf_diff__compute_wdiff(he, pair); 775 wdiff = compute_wdiff(he, pair);
776 776
777 if (wdiff != 0) 777 if (wdiff != 0)
778 scnprintf(buf, size, "%14ld", wdiff); 778 scnprintf(buf, size, "%14ld", wdiff);
779 break; 779 break;
780 780
781 case PERF_HPP_DIFF__FORMULA: 781 case PERF_HPP_DIFF__FORMULA:
782 perf_diff__formula(he, pair, buf, size); 782 formula_fprintf(he, pair, buf, size);
783 break; 783 break;
784 784
785 case PERF_HPP_DIFF__PERIOD: 785 case PERF_HPP_DIFF__PERIOD:
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 79681f62ef2b..bfcbb11c2648 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -242,11 +242,4 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused,
242#endif 242#endif
243 243
244unsigned int hists__sort_list_width(struct hists *self); 244unsigned int hists__sort_list_width(struct hists *self);
245
246double perf_diff__compute_delta(struct hist_entry *he, struct hist_entry *pair);
247double perf_diff__compute_ratio(struct hist_entry *he, struct hist_entry *pair);
248s64 perf_diff__compute_wdiff(struct hist_entry *he, struct hist_entry *pair);
249int perf_diff__formula(struct hist_entry *he, struct hist_entry *pair,
250 char *buf, size_t size);
251double perf_diff__period_percent(struct hist_entry *he, u64 period);
252#endif /* __PERF_HIST_H */ 245#endif /* __PERF_HIST_H */