delta = data[0]-data[1];
print("total: %ld\n", data[0]);
if(data[0] == 0)
exits(0);
if (!textsym(&s, 0))
error(0, "no text symbols");
tbase = s.value & ~(mach->pgsize-1); /* align down to page */
print("TEXT %.8lux\n", tbase);
/*
* Accumulate counts for each function
*/
cp = 0;
k = 0;
for (i = 0, j = (s.value-tbase)/PCRES+2; j < n; i++) {
name = s.name; /* save name */
if (!textsym(&s, i)) /* get next symbol */
break;
sum = 0;
while (j < n && j*PCRES < s.value-tbase)
sum += data[j++];
if (sum) {
cp = realloc(cp, (k+1)*sizeof(struct COUNTER));
if (cp == 0)
error(1, "realloc");
cp[k].name = name;
cp[k].time = sum;
k++;
}
}
if (!k)
error(0, "no counts");
cp[k].time = 0; /* "etext" can take no time */
/*
* Sort by time and print
*/
qsort(cp, k, sizeof(struct COUNTER), compar);
Binit(&outbuf, 1, OWRITE);
Bprint(&outbuf, " ms %% sym\n");
while(--k>=0)
Bprint(&outbuf, "%6ld\t%3lld.%lld\t%s\n",
cp[k].time,
100LL*cp[k].time/delta,
(1000LL*cp[k].time/delta)%10,
cp[k].name);
exits(0);
}