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)(sampleValue *buckets,
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);
43 Histogram(metricStyle, dataCallBack, foldCallBack, void* );
44 Histogram(Bin *buckets, metricStyle, dataCallBack, foldCallBack, void*);
45 sampleValue getValue();
46 sampleValue getValue(timeStamp start, timeStamp end);
47 int getBuckets(sampleValue *buckets, int numberOfBuckets, int first);
48 void addInterval(timeStamp start, timeStamp end,
49 sampleValue value, Boolean smooth);
50 void addPoint(timeStamp start, sampleValue value) {
51 addInterval(start, start, value, False);
53 timeStamp currentTime() {
54 return((timeStamp)(lastGlobalBin*bucketSize));
56 static int numBins; /* max bins to use */
57 static timeStamp bucketSize; /* width of a bucket */
61 void bucketValue(timeStamp start, timeStamp end,
62 sampleValue value, Boolean smooth);
64 static timeStamp total_time; /* numBins * bucketSize */
65 static int lastGlobalBin; /* global point we have data from */
66 static Histogram *allHist; /* linked list of all histograms */
68 Histogram *next; /* linked list of all histograms */
69 int lastBin; /* current (for this hist) last bin */
72 Boolean smooth; /* prevent values greater than binWidth */
73 metricStyle metricType; /* sampled function or event counter */
74 int intervalCount; /* # of intervals in use */
75 int intervalLimit; /* # of intervals in use */
80 dataCallBack dataFunc;
81 foldCallBack foldFunc;