7 #define Percent(num, max) ((max)?((num)*100)/(max):0)
11 Inst *tables[] = { itab, 0 };
17 int total, mems, arith, branch;
18 int useddelay, taken, syscall;
29 /* Compute the total so we can have percentages */
30 for(i = itab; i->func; i++)
31 if(i->name && i->count)
34 Bprint(bioout, "\nInstruction summary.\n\n");
36 for(j = 0; tables[j]; j++) {
37 for(i = tables[j]; i->func; i++) {
42 pct = Percent(i->count, total);
44 Bprint(bioout, "%-8ud %3d%% %s\n",
45 i->count, Percent(i->count,
48 Bprint(bioout, "%-8ud %s\n",
54 fatal(0, "isum bad stype %d\n", i->type);
64 useddelay += i->useddelay;
75 Bprint(bioout, "\n%-8ud Memory cycles\n", mems+total);
76 Bprint(bioout, "%-8ud %3d%% Instruction cycles\n",
77 total, Percent(total, mems+total));
78 Bprint(bioout, "%-8ud %3d%% Data cycles\n\n",
79 mems, Percent(mems, mems+total));
81 Bprint(bioout, "%-8ud %3d%% Arithmetic\n",
82 arith, Percent(arith, total));
84 Bprint(bioout, "%-8ud %3d%% System calls\n",
85 syscall, Percent(syscall, total));
87 Bprint(bioout, "%-8ud %3d%% Branches\n",
88 branch, Percent(branch, total));
90 Bprint(bioout, " %-8ud %3d%% Branches taken\n",
91 taken, Percent(taken, branch));
93 Bprint(bioout, " %-8ud %3d%% Delay slots\n",
94 useddelay, Percent(useddelay, branch));
96 Bprint(bioout, " %-8ud %3d%% Unused delay slots\n",
97 branch-useddelay, Percent(branch-useddelay, branch));
99 Bprint(bioout, "%-8ud %3d%% Program total delay slots\n",
100 nopcount, Percent(nopcount, total));
109 Bprint(bioout, "\n\nTlb summary\n");
111 Bprint(bioout, "\n%-8d User entries\n", tlb.tlbsize);
112 Bprint(bioout, "%-8d Accesses\n", tlb.hit+tlb.miss);
113 Bprint(bioout, "%-8d Tlb hits\n", tlb.hit);
114 Bprint(bioout, "%-8d Tlb misses\n", tlb.miss);
115 Bprint(bioout, "%7d%% Hit rate\n", Percent(tlb.hit, tlb.hit+tlb.miss));
118 char *stype[] = { "Stack", "Text", "Data", "Bss" };
126 Bprint(bioout, "\n\nMemory Summary\n\n");
127 Bprint(bioout, " Base End Resident References\n");
128 for(i = 0; i < Nseg; i++) {
130 Bprint(bioout, "%-5s %.8lux %.8lux %-8d %-8d\n",
131 stype[i], s->base, s->end, s->rss*BY2PG, s->refs);
135 typedef struct Prof Prof;
144 profcmp(void *va, void *vb)
150 return b->count - a->count;
159 extern ulong textbase;
163 if(textsym(&p->s, i) == 0)
168 if(textsym(&n->s, i) == 0)
170 b = (p->s.value-textbase)/PROFGRAN;
171 e = (n->s.value-textbase)/PROFGRAN;
173 p->count += iprof[b++];
178 qsort(prof, i, sizeof(Prof), profcmp);
181 for(b = 0; b < i; b++)
182 total += prof[b].count;
184 Bprint(bioout, " cycles %% symbol file\n");
185 for(b = 0; b < i; b++) {
186 if(prof[b].count == 0)
189 Bprint(bioout, "%8ld %3ld.%ld %-15s ",
191 100*prof[b].count/total,
192 (1000*prof[b].count/total)%10,
195 printsource(prof[b].s.value);
198 memset(prof, 0, sizeof(Prof)*i);