1
/* This file is part of hp2ps, a graph drawer for memory profiles.
2
Copyright (C) 2002 The University Court of the University of Glasgow.
3
This program is governed by the license contained in the file LICENSE. */
11
#include "Utilities.h"
14
#include "TopTwenty.h"
17
* We only have room in the key for a maximum of 20 identifiers.
18
* We therefore choose to keep the top 20 bands --- these will
19
* be the most important ones, since this pass is performed after
20
* the threshold and standard deviation passes. If there are more
21
* than 20 bands, the excess are gathered together as an "OTHER" ]
22
* band which appears as band 20.
38
if (i <= TWENTY) return; /* nothing to do! */
40
other = (floatish*) xmalloc(nsamples * sizeof(floatish));
41
/* build a list of samples for "OTHER" */
43
compact = (i - TWENTY) + 1;
45
for (i = 0; i < nsamples; i++) {
49
for (i = 0; i < compact && i < nidents; i++) {
50
for (ch = identtable[i]->chk; ch; ch = ch->next) {
51
for (j = 0; j < ch->nd; j++) {
52
bucket = ch->d[j].bucket;
53
value = ch->d[j].value;
54
if (bucket >= nsamples)
55
Disaster("bucket out of range");
56
other[ bucket ] += value;
61
en = MakeEntry("OTHER");
64
for (i = 0; i < nsamples; i++) {
65
StoreSample(en, i, other[i]);
68
/* slide samples down */
69
for (i = compact; i < nidents; i++) {
70
identtable[i-compact+1] = identtable[i];