4 #include "util/h/list.h"
5 #include "rtinst/h/trace.h"
12 typedef double timeStamp;
20 typedef enum { HistInterval, HistBucket } histType;
21 typedef enum { HistNewValue, HistNewTimeBase } callType;
22 typedef sampleValue Bin;
24 typedef void (*foldCallBack)(timeStamp, void* userData);
26 typedef void (*dataCallBack)(timeStamp st,
33 typedef enum { histActive, histInactive } histStatus;
34 typedef enum { histSum, histAverage } histCompact;
35 typedef enum { histSplit, histSet } histAddMode;
36 typedef enum { EventCounter, SampledFunction } metricStyle;
39 friend class histDisplay;
40 void newDataFunc(callType type, timeStamp time, void* userData);
42 Histogram(metricStyle, dataCallBack, foldCallBack, void* );
43 Histogram(Bin *buckets, metricStyle, dataCallBack, foldCallBack, void*);
44 sampleValue getValue();
45 sampleValue getValue(timeStamp start, timeStamp end);
46 void addInterval(timeStamp start, timeStamp end,
47 sampleValue value, Boolean smooth);
48 void addPoint(timeStamp start, sampleValue value) {
49 addInterval(start, start, value, False);
51 timeStamp currentTime() {
52 return((timeStamp)(lastGlobalBin*bucketSize));
54 static int numBins; /* max bins to use */
58 void bucketValue(timeStamp start, timeStamp end,
59 sampleValue value, Boolean smooth);
61 static timeStamp bucketSize; /* width of a bucket */
62 static timeStamp total_time; /* numBins * bucketSize */
63 static int lastGlobalBin; /* global point we have data from */
64 static Histogram *allHist; /* linked list of all histograms */
66 Histogram *next; /* linked list of all histograms */
67 int lastBin; /* current (for this hist) last bin */
70 Boolean smooth; /* prevent values greater than binWidth */
71 metricStyle metricType; /* sampled function or event counter */
72 int intervalCount; /* # of intervals in use */
73 int intervalLimit; /* # of intervals in use */
78 dataCallBack dataFunc;
79 foldCallBack foldFunc;