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