9 #define Percent(num, max) (int)(((vlong)(num)*100)/(max))
11 Inset *tables[] = { &ops0, &ops19, &ops31, &ops59, &ops63a, &ops63b, 0 };
18 int total, loads, stores, arith, branch;
19 int taken, powerreg, syscall, realarith, control;
32 /* Compute the total so we can have percentages */
33 for(j = 0; tables[j]; j++)
34 for(k = tables[j]->nel; --k >= 0;) {
35 i = &tables[j]->tab[k];
36 if(i->name && i->func)
40 Bprint(bioout, "\nInstruction summary.\n\n");
42 for(j = 0; tables[j]; j++) {
43 for(k =tables[j]->nel; --k>=0; ) {
44 i = &tables[j]->tab[k];
45 if(i->name && i->func) {
48 pct = Percent(i->count, total);
50 Bprint(bioout, "%-8ud %3d%% %s\n",
51 i->count, Percent(i->count, total), i->name);
53 Bprint(bioout, "%-8ud %s\n",
58 fatal(0, "isum bad stype %d\n", i->type);
80 realarith += i->count;
94 Bprint(bioout, "\n%-8ud Memory cycles\n", loads+stores+total);
99 Bprint(bioout, "%-8ud %3d%% Instruction cycles\n",
100 total, Percent(total, loads+stores+total));
102 Bprint(bioout, "%-8ud %3d%% Data cycles\n\n",
103 loads+stores, Percent(loads+stores, loads+stores+total));
105 Bprint(bioout, "%-8ud %3d%% Stores\n", stores, Percent(stores, total));
107 Bprint(bioout, "%-8ud %3d%% Loads\n", loads, Percent(loads, total));
109 Bprint(bioout, " %-8ud Store stall\n", stores*2);
111 Bprint(bioout, " %-8lud Load stall\n", loadlock);
113 Bprint(bioout, "%-8ud %3d%% Arithmetic\n", arith, Percent(arith, total));
115 Bprint(bioout, "%-8ud %3d%% Floating point\n",
116 realarith, Percent(realarith, total));
118 Bprint(bioout, "%-8ud %3d%% PowerPC special register load/stores\n",
119 powerreg, Percent(powerreg, total));
121 Bprint(bioout, "%-8ud %3d%% PowerPC control instructions\n",
122 control, Percent(control, total));
124 Bprint(bioout, "%-8ud %3d%% System calls\n", syscall, Percent(syscall, total));
126 Bprint(bioout, "%-8ud %3d%% Branches\n", branch, Percent(branch, total));
128 Bprint(bioout, " %-8ud %3d%% Branches taken\n",
129 taken, Percent(taken, branch));
132 char *stype[] = { "Stack", "Text", "Data", "Bss" };
140 Bprint(bioout, "\n\nMemory Summary\n\n");
141 Bprint(bioout, " Base End Resident References\n");
142 for(i = 0; i < Nseg; i++) {
144 Bprint(bioout, "%-5s %.8lux %.8lux %-8d %-8d\n",
145 stype[i], s->base, s->end, s->rss*BY2PG, s->refs);
149 typedef struct Prof Prof;
158 profcmp(void *a, void *b)
160 return ((Prof*)b)->count - ((Prof*)a)->count;
169 extern ulong textbase;
173 if(textsym(&p->s, i) == 0)
178 if(textsym(&n->s, i) == 0)
180 b = (p->s.value-textbase)/PROFGRAN;
181 e = (n->s.value-textbase)/PROFGRAN;
183 p->count += iprof[b++];
188 qsort(prof, i, sizeof(Prof), profcmp);
191 for(b = 0; b < i; b++)
192 total += prof[b].count;
194 Bprint(bioout, " cycles %% symbol file\n");
195 for(b = 0; b < i; b++) {
196 if(prof[b].count == 0)
199 Bprint(bioout, "%8ld %3ld.%ld %-15s ",
201 100*prof[b].count/total,
202 (1000*prof[b].count/total)%10,
205 printsource(prof[b].s.value);
208 memset(prof, 0, sizeof(Prof)*i);