29 using System.Collections.Generic;
33 using OpenMetaverse.StructuredData;
35 namespace OpenSim.Framework.Monitoring
43 private int m_timeBase;
44 private int m_numBuckets;
45 private int m_bucketMilliseconds;
46 private int m_lastBucket;
47 private int m_totalHistogramMilliseconds;
48 private long[] m_histogram;
49 private object histoLock =
new object();
53 m_numBuckets = numberOfBuckets;
54 m_bucketMilliseconds = millisecondsPerBucket;
55 m_totalHistogramMilliseconds = m_numBuckets * m_bucketMilliseconds;
57 m_histogram =
new long[m_numBuckets];
60 m_timeBase = Util.EnvironmentTickCount();
74 int bucketTime = Util.EnvironmentTickCountSubtract(m_timeBase);
77 if (bucketTime > m_totalHistogramMilliseconds)
81 m_timeBase = Util.EnvironmentTickCount();
86 int bucket = bucketTime / m_bucketMilliseconds;
89 while (bucket != m_lastBucket)
92 for (
int jj = m_lastBucket + 1; jj <= Math.Min(bucket, m_numBuckets - 1); jj++)
96 m_lastBucket = bucket;
98 if (bucket > m_numBuckets)
100 bucket -= m_numBuckets;
102 m_histogram[m_lastBucket] = 0;
103 m_timeBase += m_totalHistogramMilliseconds;
107 m_histogram[m_lastBucket] += cnt;
114 long[] ret =
new long[m_numBuckets];
117 int indx = m_lastBucket + 1;
118 for (
int ii = 0; ii < m_numBuckets; ii++, indx++)
120 if (indx >= m_numBuckets)
122 ret[ii] = m_histogram[indx];
132 ret.Add(
"Buckets", OSD.FromInteger(m_numBuckets));
133 ret.Add(
"BucketMilliseconds", OSD.FromInteger(m_bucketMilliseconds));
134 ret.Add(
"TotalMilliseconds", OSD.FromInteger(m_totalHistogramMilliseconds));
138 int baseBucketNum = (m_timeBase / m_bucketMilliseconds) + m_lastBucket + 1;
139 ret.Add(
"BaseNumber", OSD.FromInteger(baseBucketNum));
141 ret.Add(
"Values", GetHistogramAsOSDArray());
151 int indx = m_lastBucket + 1;
152 for (
int ii = 0; ii < m_numBuckets; ii++, indx++)
154 if (indx >= m_numBuckets)
156 ret[ii] = OSD.FromLong(m_histogram[indx]);
167 for (
int ii = 0; ii < m_numBuckets; ii++)
OpenMetaverse.StructuredData.OSDArray OSDArray
OSDArray GetHistogramAsOSDArray()
OpenMetaverse.StructuredData.OSDMap OSDMap
OSDMap GetHistogramAsOSDMap()
EventHistogram(int numberOfBuckets, int millisecondsPerBucket)