aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2013-02-03 14:08:34 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-07-12 12:54:07 -0400
commit345dc0b45ecc37a239723f2b6392cab04d8b0eff (patch)
tree064682f63687367eff7dcce1e0f66012d9614cec /tools/perf/ui
parent1d81c7fc25c0f0559e3306fc73ecfe78b740c9e8 (diff)
perf diff: Move diff related columns into diff command
Moving diff related columns into diff command, because they are not used by any other command. Also moving the column entry functions under generic one with baseline as an exception. 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-v58qfl75xkqojz54h1v5fy6p@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r--tools/perf/ui/hist.c209
1 files changed, 1 insertions, 208 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index a359b75ce800..dc900d7a190e 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -163,207 +163,6 @@ HPP_PERCENT_FNS(overhead_guest_us, "guest usr", period_guest_us, 9, 8)
163HPP_RAW_FNS(samples, "Samples", nr_events, 12, 12) 163HPP_RAW_FNS(samples, "Samples", nr_events, 12, 12)
164HPP_RAW_FNS(period, "Period", period, 12, 12) 164HPP_RAW_FNS(period, "Period", period, 12, 12)
165 165
166
167static int hpp__header_baseline(struct perf_hpp_fmt *fmt __maybe_unused,
168 struct perf_hpp *hpp)
169{
170 return scnprintf(hpp->buf, hpp->size, "Baseline");
171}
172
173static int hpp__width_baseline(struct perf_hpp_fmt *fmt __maybe_unused,
174 struct perf_hpp *hpp __maybe_unused)
175{
176 return 8;
177}
178
179static double baseline_percent(struct hist_entry *he)
180{
181 struct hists *hists = he->hists;
182 return 100.0 * he->stat.period / hists->stats.total_period;
183}
184
185static int hpp__color_baseline(struct perf_hpp_fmt *fmt __maybe_unused,
186 struct perf_hpp *hpp, struct hist_entry *he)
187{
188 double percent = baseline_percent(he);
189
190 if (!he->dummy)
191 return percent_color_snprintf(hpp->buf, hpp->size,
192 " %6.2f%%", percent);
193 else
194 return scnprintf(hpp->buf, hpp->size, " ");
195}
196
197static int hpp__entry_baseline(struct perf_hpp_fmt *_fmt __maybe_unused,
198 struct perf_hpp *hpp, struct hist_entry *he)
199{
200 double percent = baseline_percent(he);
201 const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%";
202
203 if (!he->dummy)
204 return scnprintf(hpp->buf, hpp->size, fmt, percent);
205 else
206 return scnprintf(hpp->buf, hpp->size, " ");
207}
208
209static int hpp__header_period_baseline(struct perf_hpp_fmt *_fmt __maybe_unused,
210 struct perf_hpp *hpp)
211{
212 const char *fmt = symbol_conf.field_sep ? "%s" : "%12s";
213
214 return scnprintf(hpp->buf, hpp->size, fmt, "Period Base");
215}
216
217static int hpp__width_period_baseline(struct perf_hpp_fmt *fmt __maybe_unused,
218 struct perf_hpp *hpp __maybe_unused)
219{
220 return 12;
221}
222
223static int hpp__entry_period_baseline(struct perf_hpp_fmt *_fmt __maybe_unused,
224 struct perf_hpp *hpp, struct hist_entry *he)
225{
226 struct hist_entry *pair = hist_entry__next_pair(he);
227 u64 period = pair ? pair->stat.period : 0;
228 const char *fmt = symbol_conf.field_sep ? "%" PRIu64 : "%12" PRIu64;
229
230 return scnprintf(hpp->buf, hpp->size, fmt, period);
231}
232
233static int hpp__header_delta(struct perf_hpp_fmt *_fmt __maybe_unused,
234 struct perf_hpp *hpp)
235{
236 const char *fmt = symbol_conf.field_sep ? "%s" : "%7s";
237
238 return scnprintf(hpp->buf, hpp->size, fmt, "Delta");
239}
240
241static int hpp__width_delta(struct perf_hpp_fmt *fmt __maybe_unused,
242 struct perf_hpp *hpp __maybe_unused)
243{
244 return 7;
245}
246
247static int hpp__entry_delta(struct perf_hpp_fmt *_fmt __maybe_unused,
248 struct perf_hpp *hpp, struct hist_entry *he)
249{
250 struct hist_entry *pair = hist_entry__next_pair(he);
251 const char *fmt = symbol_conf.field_sep ? "%s" : "%7.7s";
252 char buf[32] = " ";
253 double diff = 0.0;
254
255 if (pair) {
256 if (he->diff.computed)
257 diff = he->diff.period_ratio_delta;
258 else
259 diff = perf_diff__compute_delta(he, pair);
260 }
261
262 if (fabs(diff) >= 0.01)
263 scnprintf(buf, sizeof(buf), "%+4.2F%%", diff);
264
265 return scnprintf(hpp->buf, hpp->size, fmt, buf);
266}
267
268static int hpp__header_ratio(struct perf_hpp_fmt *_fmt __maybe_unused,
269 struct perf_hpp *hpp)
270{
271 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
272
273 return scnprintf(hpp->buf, hpp->size, fmt, "Ratio");
274}
275
276static int hpp__width_ratio(struct perf_hpp_fmt *fmt __maybe_unused,
277 struct perf_hpp *hpp __maybe_unused)
278{
279 return 14;
280}
281
282static int hpp__entry_ratio(struct perf_hpp_fmt *_fmt __maybe_unused,
283 struct perf_hpp *hpp, struct hist_entry *he)
284{
285 struct hist_entry *pair = hist_entry__next_pair(he);
286 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
287 char buf[32] = " ";
288 double ratio = 0.0;
289
290 /* No point for ratio number if we are dummy.. */
291 if (!he->dummy && pair) {
292 if (he->diff.computed)
293 ratio = he->diff.period_ratio;
294 else
295 ratio = perf_diff__compute_ratio(he, pair);
296 }
297
298 if (ratio > 0.0)
299 scnprintf(buf, sizeof(buf), "%+14.6F", ratio);
300
301 return scnprintf(hpp->buf, hpp->size, fmt, buf);
302}
303
304static int hpp__header_wdiff(struct perf_hpp_fmt *_fmt __maybe_unused,
305 struct perf_hpp *hpp)
306{
307 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
308
309 return scnprintf(hpp->buf, hpp->size, fmt, "Weighted diff");
310}
311
312static int hpp__width_wdiff(struct perf_hpp_fmt *fmt __maybe_unused,
313 struct perf_hpp *hpp __maybe_unused)
314{
315 return 14;
316}
317
318static int hpp__entry_wdiff(struct perf_hpp_fmt *_fmt __maybe_unused,
319 struct perf_hpp *hpp, struct hist_entry *he)
320{
321 struct hist_entry *pair = hist_entry__next_pair(he);
322 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
323 char buf[32] = " ";
324 s64 wdiff = 0;
325
326 /* No point for wdiff number if we are dummy.. */
327 if (!he->dummy && pair) {
328 if (he->diff.computed)
329 wdiff = he->diff.wdiff;
330 else
331 wdiff = perf_diff__compute_wdiff(he, pair);
332 }
333
334 if (wdiff != 0)
335 scnprintf(buf, sizeof(buf), "%14ld", wdiff);
336
337 return scnprintf(hpp->buf, hpp->size, fmt, buf);
338}
339
340static int hpp__header_formula(struct perf_hpp_fmt *_fmt __maybe_unused,
341 struct perf_hpp *hpp)
342{
343 const char *fmt = symbol_conf.field_sep ? "%s" : "%70s";
344
345 return scnprintf(hpp->buf, hpp->size, fmt, "Formula");
346}
347
348static int hpp__width_formula(struct perf_hpp_fmt *fmt __maybe_unused,
349 struct perf_hpp *hpp __maybe_unused)
350{
351 return 70;
352}
353
354static int hpp__entry_formula(struct perf_hpp_fmt *_fmt __maybe_unused,
355 struct perf_hpp *hpp, struct hist_entry *he)
356{
357 struct hist_entry *pair = hist_entry__next_pair(he);
358 const char *fmt = symbol_conf.field_sep ? "%s" : "%-70s";
359 char buf[96] = " ";
360
361 if (pair)
362 perf_diff__formula(he, pair, buf, sizeof(buf));
363
364 return scnprintf(hpp->buf, hpp->size, fmt, buf);
365}
366
367#define HPP__COLOR_PRINT_FNS(_name) \ 166#define HPP__COLOR_PRINT_FNS(_name) \
368 { \ 167 { \
369 .header = hpp__header_ ## _name, \ 168 .header = hpp__header_ ## _name, \
@@ -380,19 +179,13 @@ static int hpp__entry_formula(struct perf_hpp_fmt *_fmt __maybe_unused,
380 } 179 }
381 180
382struct perf_hpp_fmt perf_hpp__format[] = { 181struct perf_hpp_fmt perf_hpp__format[] = {
383 HPP__COLOR_PRINT_FNS(baseline),
384 HPP__COLOR_PRINT_FNS(overhead), 182 HPP__COLOR_PRINT_FNS(overhead),
385 HPP__COLOR_PRINT_FNS(overhead_sys), 183 HPP__COLOR_PRINT_FNS(overhead_sys),
386 HPP__COLOR_PRINT_FNS(overhead_us), 184 HPP__COLOR_PRINT_FNS(overhead_us),
387 HPP__COLOR_PRINT_FNS(overhead_guest_sys), 185 HPP__COLOR_PRINT_FNS(overhead_guest_sys),
388 HPP__COLOR_PRINT_FNS(overhead_guest_us), 186 HPP__COLOR_PRINT_FNS(overhead_guest_us),
389 HPP__PRINT_FNS(samples), 187 HPP__PRINT_FNS(samples),
390 HPP__PRINT_FNS(period), 188 HPP__PRINT_FNS(period)
391 HPP__PRINT_FNS(period_baseline),
392 HPP__PRINT_FNS(delta),
393 HPP__PRINT_FNS(ratio),
394 HPP__PRINT_FNS(wdiff),
395 HPP__PRINT_FNS(formula)
396}; 189};
397 190
398LIST_HEAD(perf_hpp__list); 191LIST_HEAD(perf_hpp__list);