#include "perf.h"
#include "util/symbol.h"
+#include "util/color.h"
#include "util/util.h"
#include "util/rbtree.h"
#include "util/parse-options.h"
static int group = 0;
static unsigned int page_size;
static unsigned int mmap_pages = 16;
-static int use_mmap = 0;
-static int use_munmap = 0;
static int freq = 0;
static char *sym_filter;
for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) {
struct sym_entry *syme = rb_entry(nd, struct sym_entry, rb_node);
struct symbol *sym = (struct symbol *)(syme + 1);
- float pcnt;
+ char *color = PERF_COLOR_NORMAL;
+ double pcnt;
if (++printed > print_entries || syme->snap_count < count_filter)
continue;
pcnt = 100.0 - (100.0 * ((sum_kevents - syme->snap_count) /
sum_kevents));
+ /*
+ * We color high-overhead entries in red, low-overhead
+ * entries in green - and keep the middle ground normal:
+ */
+ if (pcnt >= 5.0)
+ color = PERF_COLOR_RED;
+ if (pcnt < 0.5)
+ color = PERF_COLOR_GREEN;
+
if (nr_counters == 1)
- printf("%19.2f - %4.1f%% - %016llx : %s\n",
- syme->weight, pcnt, sym->start, sym->name);
+ printf("%19.2f - ", syme->weight);
else
- printf("%8.1f %10ld - %4.1f%% - %016llx : %s\n",
- syme->weight, syme->snap_count,
- pcnt, sym->start, sym->name);
+ printf("%8.1f %10ld - ", syme->weight, syme->snap_count);
+
+ color_fprintf(stdout, color, "%4.1f%%", pcnt);
+ printf(" - %016llx : %s\n", sym->start, sym->name);
}
{
if (kernel_dso == NULL)
return -1;
- if (dso__load_kernel(kernel_dso, NULL, symbol_filter) != 0)
+ if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) != 0)
goto out_delete_dso;
node = rb_first(&kernel_dso->syms);
if (event->header.misc & PERF_EVENT_MISC_OVERFLOW) {
if (event->header.type & PERF_SAMPLE_IP)
process_event(event->ip.ip, md->counter);
- } else {
- switch (event->header.type) {
- case PERF_EVENT_MMAP:
- case PERF_EVENT_MUNMAP:
- printf("%s: %Lu %Lu %Lu %s\n",
- event->header.type == PERF_EVENT_MMAP
- ? "mmap" : "munmap",
- event->mmap.start,
- event->mmap.len,
- event->mmap.pgoff,
- event->mmap.filename);
- break;
- }
}
}
attr.config = event_id[counter];
attr.sample_period = event_count[counter];
attr.sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID;
- attr.mmap = use_mmap;
- attr.munmap = use_munmap;
attr.freq = freq;
fd[i][counter] = sys_perf_counter_open(&attr, target_pid, cpu, group_fd, 0);
"only display symbols matchig this pattern"),
OPT_BOOLEAN('z', "zero", &group,
"zero history across updates"),
- OPT_BOOLEAN('M', "use-mmap", &use_mmap,
- "track mmap events"),
- OPT_BOOLEAN('U', "use-munmap", &use_munmap,
- "track munmap events"),
OPT_INTEGER('F', "freq", &freq,
"profile at this frequency"),
OPT_INTEGER('E', "entries", &print_entries,