示例#1
0
        public void GetSumOfHiccupsAndTime()
        {
            LinealBufferHiccupCounter counter = new LinealBufferHiccupCounter();

            float hiccups     = 0.0f;
            float totalTime   = 0.0f;
            int   hiccupCount = 0;

            // Fill in random values
            for (int i = 0; i < 1500; i++)
            {
                float value = Random.Range(0.001f, 1f);
                counter.AddDeltaTime(value);
            }

            for (int i = 0; i < 1000; i++)
            {
                float value = Random.Range(0.001f, 1f);
                totalTime += value;
                if (value > FPSEvaluation.HICCUP_THRESHOLD_IN_SECONDS)
                {
                    hiccupCount += 1;
                    hiccups     += value;
                }

                counter.AddDeltaTime(value);
            }

            const float eps = 0.002f;

            Assert.LessOrEqual(Mathf.Abs(counter.HiccupsSum - hiccups), eps);
            Assert.AreEqual(counter.HiccupsCountInBuffer, hiccupCount);
            Assert.LessOrEqual(Mathf.Abs(counter.GetTotalSeconds() - totalTime), eps);
        }
示例#2
0
 private void GenerateHiccupReport()
 {
     WebInterface.SendPerformanceHiccupReport(tracker.CurrentHiccupCount(), tracker.GetHiccupSum(), tracker.GetTotalSeconds());
 }
        public void Update()
        {
#if !UNITY_EDITOR
            if (!CommonScriptableObjects.focusState.Get())
            {
                return;
            }
#endif
            if (!CommonScriptableObjects.rendererState.Get())
            {
                return;
            }

            var deltaInMs = Time.deltaTime * 1000;

            tracker.AddDeltaTime(Time.deltaTime);

            performanceMetricsDataVariable?.Set(tracker.CurrentFPSCount(), tracker.CurrentHiccupCount(), tracker.HiccupsSum, tracker.GetTotalSeconds());

            encodedSamples[currentIndex++] = (char)deltaInMs;

            if (currentIndex == SAMPLES_SIZE)
            {
                currentIndex = 0;
                Report(new string(encodedSamples));
            }
        }