Esempio n. 1
0
            public void AddHistogram(string path)
            {
                int barX        = 100;
                int barY        = 30;
                int textX       = barX - 60;
                int textY       = barY + 12;
                int maxWidth    = 200;
                int barHeight   = 12;
                int verticalGap = 4;

                BucketSet bucketSet = m_logData.m_bucketSets[path];

                if (bucketSet is TimeBucketSet)
                {
                    for (int i = 0; i < bucketSet.m_buckets.Count; i++)
                    {
                        TimeBucket bucket = bucketSet.m_buckets[i] as TimeBucket;
                        m_page.content += "context.fillStyle = \"rgb(255,0,0)\";\n";
                        m_page.content += string.Format("context.fillRect({0}, {1}, {2}, {3});\n", barX, barY, (bucket.m_timePercent / 100.0f) * maxWidth, barHeight);
                        m_page.content += "context.fillStyle = \"rgb(0,0,0)\";\n";
                        m_page.content += string.Format("context.fillText(\"{0}\", {1}, {2});\n", bucket.RangeDescription, textX, textY);
                        barY           += barHeight + verticalGap;
                        textY          += barHeight + verticalGap;
                    }
                }
            }
Esempio n. 2
0
            public void AddBucketsTable(string path)
            {
                BucketSet bucketSet = m_logData.m_bucketSets[path];

                if (bucketSet is TimeBucketSet)
                {
                    m_page.content += "|| Range || % of time || cumulative % ||\n";

                    for (int i = 0; i < bucketSet.m_buckets.Count; i++)
                    {
                        TimeBucket bucket = bucketSet.m_buckets[i] as TimeBucket;
                        m_page.content += string.Format("| {0} | {1:n2}% | {2:n2}% |\n", bucket.RangeDescription, bucket.m_timePercent, bucket.m_timePercentCumulative);
                    }
                }
            }
Esempio n. 3
0
        void CalculateBucketSet <T>(string name, AcceptRecord acceptRecord, GetRecordValue grv, GetRecordValue grvTime, float start, float range, float max, bool lessThanMode, int fromIdx) where T : Bucket, new()
        {
            List <Bucket> buckets;
            TimeBucketSet bucketSet;

            if (m_bucketSets.ContainsKey(name))
            {
                bucketSet = (TimeBucketSet)m_bucketSets[name];
                buckets   = bucketSet.m_buckets;
            }
            else
            {
                buckets = new List <Bucket>();

                int numBuckets = (int)((max - start) / range) + (start == 0.0f ? 1 : 2);
                for (int i = 0; i < numBuckets; i++)
                {
                    buckets.Add(new T());
                }

                bucketSet = new TimeBucketSet(buckets);
                m_bucketSets.Add(name, bucketSet);
            }

            for (int i = fromIdx; i < FrameRecords.Count; i++)
            {
                FrameRecord fr = FrameRecords[i];

                if (!acceptRecord(fr))
                {
                    continue;
                }

                float value         = grv(fr);
                float frameTimeInMS = grvTime(fr);

                if (float.IsInfinity(value))
                {
                    value = 0.0f;
                }

                int offsetScaledValue = (int)((value - start) / range);

                int bucketIdx;

                if (start == 0.0f)
                {
                    bucketIdx = offsetScaledValue;
                }
                else
                {
                    bucketIdx = (offsetScaledValue < 0) ? 0 : (offsetScaledValue + 1);
                }

                bucketIdx = Math.Max(0, Math.Min(bucketIdx, buckets.Count - 1));
                bucketIdx = buckets.Count - 1 - bucketIdx;

                TimeBucket bucket = buckets[bucketIdx] as TimeBucket;

                bucket.m_num++;
                bucket.m_timeInMS += frameTimeInMS;
                bucket.m_timeInMSClampingTo5fps += Math.Min(frameTimeInMS, 1000.0f / 5.0f);

                bucketSet.m_cumulativeNum++;
                bucketSet.m_cumulativeTimeInMS += frameTimeInMS;
                bucketSet.m_cumulativeTimeInMSClampingTo5fps += Math.Min(frameTimeInMS, 1000.0f / 5.0f);
            }

            float numPercentCumulative        = 0.0f;
            float timePercentCumulative       = 0.0f;
            float timeClamp5PercentCumulative = 0.0f;

            if (lessThanMode)
            {
                numPercentCumulative        = 100.0f;
                timePercentCumulative       = 100.0f;
                timeClamp5PercentCumulative = 100.0f;
            }

            for (int i = 0; i < buckets.Count; i++)
            {
                TimeBucket bucket = buckets[i] as TimeBucket;

                bucket.m_numPercent        = 100.0f * bucket.m_num / (float)bucketSet.m_cumulativeNum;
                bucket.m_timePercent       = 100.0f * bucket.m_timeInMS / bucketSet.m_cumulativeTimeInMS;
                bucket.m_timeClamp5Percent = 100.0f * bucket.m_timeInMSClampingTo5fps / bucketSet.m_cumulativeTimeInMSClampingTo5fps;

                if (!lessThanMode)
                {
                    numPercentCumulative        += bucket.m_numPercent;
                    timePercentCumulative       += bucket.m_timePercent;
                    timeClamp5PercentCumulative += bucket.m_timeClamp5Percent;
                }

                bucket.m_numPercentCumulative        = numPercentCumulative;
                bucket.m_timePercentCumulative       = timePercentCumulative;
                bucket.m_timeClamp5PercentCumulative = timeClamp5PercentCumulative;

                if (lessThanMode)
                {
                    numPercentCumulative        -= bucket.m_numPercent;
                    timePercentCumulative       -= bucket.m_timePercent;
                    timeClamp5PercentCumulative -= bucket.m_timeClamp5Percent;
                }

                float begin;
                float end;
                int   bucketIdx = buckets.Count - 1 - i;

                if (start == 0.0f)
                {
                    begin = bucketIdx * range;
                    end   = (bucketIdx + 1) * range;
                }
                else
                {
                    begin = (bucketIdx == 0) ? 0.0f : start + ((bucketIdx - 1) * range);
                    end   = start + (bucketIdx * range);
                }

                if (bucketIdx < buckets.Count - 1)
                {
                    if (lessThanMode)
                    {
                        bucket.RangeDescription = string.Format("<{0:n0}", end);
                    }
                    else
                    {
                        bucket.RangeDescription = string.Format("{0:n0} - {1:n0}", begin, end);
                    }
                }
                else
                {
                    if (lessThanMode)
                    {
                        bucket.RangeDescription = string.Format("{0:n0}+", begin);
                    }
                    else
                    {
                        bucket.RangeDescription = string.Format("{0:n0} -", begin);
                    }
                }
            }
        }