10 #include "TraceElement.h"
13 * Compute the total volume for each identifier, and the grand
14 * total of these totals. The identifiers whose totals when
15 * added together amount to less that a threshold percentage
16 * (default 1%) of the grand total are considered to be ``trace
17 * elements'' and they are thrown away.
20 extern floatish thresholdpercent;
34 totals = (intish *) xmalloc(nidents * sizeof(intish));
38 for (i = 0; i < nidents; i++) {
42 for (i = 0; i < nidents; i++) {
43 for (ch = identtable[i]->chk; ch; ch = ch->next) {
44 for (j = 0; j < ch->nd; j++) {
45 totals[ i ] += ch->d[j].value;
50 /* sort on the basis of total */
52 for (i = 0; i < nidents-1; i++) {
54 for (j = i+1; j < nidents; j++) {
55 if (totals[ j ] < totals[ min ]) {
61 totals[ min ] = totals[ i ];
64 e = identtable[ min ];
65 identtable[ min ] = identtable[ i ];
70 /* find the grand total (NB: can get *BIG*!) */
74 for (i = 0; i < nidents; i++) {
75 grandtotal += (floatish) totals[ i ];
78 t = 0.0; /* cumulative percentage */
80 for (i = 0; i < nidents; i++) {
81 p = (100.0 * (floatish) totals[i]) / grandtotal;
83 if (t >= THRESHOLD_PERCENT) {
88 /* identifiers from 0 to i-1 should be removed */
89 for (j = 0; i < nidents; i++, j++) {
90 identtable[j] = identtable[i];