3 #include "../util/hist.h"
4 #include "../util/util.h"
5 #include "../util/sort.h"
9 static int hpp__header_overhead(
struct perf_hpp *hpp)
36 static int hpp__header_overhead_sys(
struct perf_hpp *hpp)
65 static int hpp__header_overhead_us(
struct perf_hpp *hpp)
94 static int hpp__header_overhead_guest_sys(
struct perf_hpp *hpp)
104 static int hpp__color_overhead_guest_sys(
struct perf_hpp *hpp,
108 double percent = 100.0 * he->
stat.period_guest_sys / hists->
stats.total_period;
113 static int hpp__entry_overhead_guest_sys(
struct perf_hpp *hpp,
117 double percent = 100.0 * he->
stat.period_guest_sys / hists->
stats.total_period;
123 static int hpp__header_overhead_guest_us(
struct perf_hpp *hpp)
133 static int hpp__color_overhead_guest_us(
struct perf_hpp *hpp,
137 double percent = 100.0 * he->
stat.period_guest_us / hists->
stats.total_period;
142 static int hpp__entry_overhead_guest_us(
struct perf_hpp *hpp,
146 double percent = 100.0 * he->
stat.period_guest_us / hists->
stats.total_period;
152 static int hpp__header_baseline(
struct perf_hpp *hpp)
162 static double baseline_percent(
struct hist_entry *he)
169 u64 total_period = pair_hists->
stats.total_period;
170 u64 base_period = pair->
stat.period;
172 percent = 100.0 * base_period / total_period;
180 double percent = baseline_percent(he);
187 double percent = baseline_percent(he);
193 static int hpp__header_samples(
struct perf_hpp *hpp)
212 static int hpp__header_period(
struct perf_hpp *hpp)
231 static int hpp__header_delta(
struct perf_hpp *hpp)
248 u64 old_total, new_total;
249 double old_percent = 0, new_percent = 0;
254 old_total = pair_hists ? pair_hists->
stats.total_period : 0;
255 if (old_total > 0 && pair)
256 old_percent = 100.0 * pair->
stat.period / old_total;
258 new_total = hists->
stats.total_period;
260 new_percent = 100.0 * he->
stat.period / new_total;
262 diff = new_percent - old_percent;
263 if (
fabs(diff) >= 0.01)
264 scnprintf(buf,
sizeof(buf),
"%+4.2F%%", diff);
269 static int hpp__header_displ(
struct perf_hpp *hpp)
279 static int hpp__entry_displ(
struct perf_hpp *hpp,
288 scnprintf(buf,
sizeof(buf),
"%+4ld", displacement);
293 #define HPP__COLOR_PRINT_FNS(_name) \
294 .header = hpp__header_ ## _name, \
295 .width = hpp__width_ ## _name, \
296 .color = hpp__color_ ## _name, \
297 .entry = hpp__entry_ ## _name
299 #define HPP__PRINT_FNS(_name) \
300 .header = hpp__header_ ## _name, \
301 .width = hpp__width_ ## _name, \
302 .entry = hpp__entry_ ## _name
317 #undef HPP__COLOR_PRINT_FNS
318 #undef HPP__PRINT_FNS
345 static inline void advance_hpp(
struct perf_hpp *hpp,
int inc)
363 if (!perf_hpp__format[i].
cond)
366 if (!sep || !first) {
368 advance_hpp(hpp, ret);
372 if (color && perf_hpp__format[i].color)
373 ret = perf_hpp__format[
i].
color(hpp, he);
375 ret = perf_hpp__format[
i].
entry(hpp, he);
377 advance_hpp(hpp, ret);
394 ret +=
scnprintf(s + ret, size - ret,
"%s", sep ?:
" ");
411 if (!perf_hpp__format[i].
cond)