MFC r206090:

Improve "top" header by:
- Display sample received per PMCs (or merged PMCs).
- Display percentage vs all samples
This commit is contained in:
Fabien Thomas 2010-04-12 21:37:28 +00:00
parent 31810d290b
commit 18f2288474
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/8/; revision=206513
4 changed files with 59 additions and 13 deletions

View File

@ -341,6 +341,7 @@ pmcpl_cg_process(struct pmcstat_process *pp, struct pmcstat_pmcrecord *pmcr,
parent = pmcstat_cgnode_hash_lookup_pc(pp, pmcid, pc, usermode);
if (parent == NULL) {
pmcstat_stats.ps_callchain_dubious_frames++;
pmcr->pr_dubious_frames++;
return;
}

View File

@ -403,6 +403,10 @@ pmcpl_ct_node_dumptop(int pmcin, struct pmcpl_ct_node *ct,
&pmcin, pmcpl_ct_arc_compare);
for (i = 0; i < ct->pct_narc; i++) {
/* Skip this arc if there is no sample at all. */
if (PMCPL_CT_SAMPLE(pmcin,
&ct->pct_arc[i].pcta_samples) == 0)
continue;
if (PMCPL_CT_SAMPLEP(pmcin,
&ct->pct_arc[i].pcta_samples) > pmcstat_threshold) {
if (pmcpl_ct_node_dumptop(pmcin,
@ -516,6 +520,10 @@ pmcpl_ct_topdisplay(void)
x = y = 0;
for (i = 0; i < pmcpl_ct_root->pct_narc; i++) {
/* Skip this arc if there is no sample at all. */
if (PMCPL_CT_SAMPLE(pmcin,
&pmcpl_ct_root->pct_arc[i].pcta_samples) == 0)
continue;
if (pmcpl_ct_node_dumptop(pmcin,
pmcpl_ct_root->pct_arc[i].pcta_child,
&rsamples, x, &y, pmcstat_displayheight - 2)) {
@ -693,6 +701,7 @@ pmcpl_ct_process(struct pmcstat_process *pp, struct pmcstat_pmcrecord *pmcr,
}
if (n-- == 0) {
pmcstat_stats.ps_callchain_dubious_frames++;
pmcr->pr_dubious_frames++;
return;
}

View File

@ -247,6 +247,7 @@ static int pmcstat_string_compute_hash(const char *_string);
static void pmcstat_string_initialize(void);
static int pmcstat_string_lookup_hash(pmcstat_interned_string _is);
static void pmcstat_string_shutdown(void);
static void pmcstat_stats_reset(void);
/*
* A simple implementation of interned strings. Each interned string
@ -274,6 +275,21 @@ int pmcstat_npmcs;
*/
int pmcstat_pause;
static void
pmcstat_stats_reset(void)
{
struct pmcstat_pmcrecord *pr;
/* Flush PMCs stats. */
LIST_FOREACH(pr, &pmcstat_pmcs, pr_next) {
pr->pr_samples = 0;
pr->pr_dubious_frames = 0;
}
/* Flush global stats. */
bzero(&pmcstat_stats, sizeof(struct pmcstat_stats));
}
/*
* Compute a 'hash' value for a string.
*/
@ -1009,6 +1025,8 @@ pmcstat_pmcid_add(pmc_id_t pmcid, pmcstat_interned_string ps)
pr->pr_pmcid = pmcid;
pr->pr_pmcname = ps;
pr->pr_pmcin = pmcstat_npmcs++;
pr->pr_samples = 0;
pr->pr_dubious_frames = 0;
pr->pr_merge = prm == NULL ? pr : prm;
LIST_INSERT_HEAD(&pmcstat_pmcs, pr, pr_next);
@ -1387,6 +1405,7 @@ pmcstat_analyze_log(void)
/* Get PMC record. */
pmcr = pmcstat_lookup_pmcid(ev.pl_u.pl_s.pl_pmcid);
assert(pmcr != NULL);
pmcr->pr_samples++;
/*
* Call the plugins processing
@ -1420,6 +1439,7 @@ pmcstat_analyze_log(void)
/* Get PMC record. */
pmcr = pmcstat_lookup_pmcid(ev.pl_u.pl_cc.pl_pmcid);
assert(pmcr != NULL);
pmcr->pr_samples++;
/*
* Call the plugins processing
@ -1787,32 +1807,46 @@ pmcstat_process_log(void)
static void
pmcstat_refresh_top(void)
{
int v_attrs;
float v;
char pmcname[40];
const char *s;
struct pmcstat_pmcrecord *pmcpr;
/* If in pause mode do not refresh display. */
if (pmcstat_pause)
return;
/* Wait until PMC pop in the log. */
s = pmcstat_pmcindex_to_name(pmcstat_pmcinfilter);
if (s == NULL)
pmcpr = pmcstat_pmcindex_to_pmcr(pmcstat_pmcinfilter);
if (pmcpr == NULL)
return;
/* Format PMC name. */
if (pmcstat_mergepmc)
snprintf(pmcname, sizeof(pmcname), "[%s]", s);
snprintf(pmcname, sizeof(pmcname), "[%s]",
pmcstat_string_unintern(pmcpr->pr_pmcname));
else
snprintf(pmcname, sizeof(pmcname), "%s.%d",
s, pmcstat_pmcinfilter);
pmcstat_string_unintern(pmcpr->pr_pmcname),
pmcstat_pmcinfilter);
/* Format samples count. */
if (pmcstat_stats.ps_samples_total > 0)
v = (pmcpr->pr_samples * 100.0) /
pmcstat_stats.ps_samples_total;
else
v = 0.;
v_attrs = PMCSTAT_ATTRPERCENT(v);
PMCSTAT_PRINTBEGIN();
PMCSTAT_PRINTW("PMC: %s Samples: %u processed, %u invalid\n\n",
PMCSTAT_PRINTW("PMC: %s Samples: %u ",
pmcname,
pmcstat_stats.ps_samples_total,
pmcstat_stats.ps_samples_unknown_offset +
pmcstat_stats.ps_samples_indeterminable +
pmcstat_stats.ps_callchain_dubious_frames);
pmcpr->pr_samples);
PMCSTAT_ATTRON(v_attrs);
PMCSTAT_PRINTW("(%.1f%%) ", v);
PMCSTAT_ATTROFF(v_attrs);
PMCSTAT_PRINTW(", %u unresolved\n\n",
pmcpr->pr_dubious_frames);
if (plugins[args.pa_plugin].pl_topdisplay != NULL)
plugins[args.pa_plugin].pl_topdisplay();
PMCSTAT_PRINTEND();
@ -1879,7 +1913,7 @@ pmcstat_keypress_log(void)
*/
if (plugins[args.pa_plugin].pl_shutdown != NULL)
plugins[args.pa_plugin].pl_shutdown(NULL);
bzero(&pmcstat_stats, sizeof(struct pmcstat_stats));
pmcstat_stats_reset();
if (plugins[args.pa_plugin].pl_init != NULL)
plugins[args.pa_plugin].pl_init();
@ -1900,7 +1934,7 @@ pmcstat_keypress_log(void)
} while (plugins[args.pa_plugin].pl_topdisplay == NULL);
/* Open new plugin. */
bzero(&pmcstat_stats, sizeof(struct pmcstat_stats));
pmcstat_stats_reset();
if (plugins[args.pa_plugin].pl_init != NULL)
plugins[args.pa_plugin].pl_init();
wprintw(w, "switching to plugin %s",
@ -1949,7 +1983,7 @@ pmcstat_display_log(void)
if (args.pa_topmode == PMCSTAT_TOP_DELTA) {
if (plugins[args.pa_plugin].pl_shutdown != NULL)
plugins[args.pa_plugin].pl_shutdown(NULL);
bzero(&pmcstat_stats, sizeof(struct pmcstat_stats));
pmcstat_stats_reset();
if (plugins[args.pa_plugin].pl_init != NULL)
plugins[args.pa_plugin].pl_init();
}

View File

@ -146,6 +146,8 @@ struct pmcstat_pmcrecord {
pmc_id_t pr_pmcid;
int pr_pmcin;
pmcstat_interned_string pr_pmcname;
int pr_samples;
int pr_dubious_frames;
struct pmcstat_pmcrecord *pr_merge;
};
extern LIST_HEAD(pmcstat_pmcs, pmcstat_pmcrecord) pmcstat_pmcs; /* PMC list */