Пример #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
        public void DetectsOneHiccup()
        {
            LinealBufferHiccupCounter counter = new LinealBufferHiccupCounter();

            const float tenMillis = 0.01f;

            for (int i = 0; i < 100; i++)
            {
                counter.AddDeltaTime(tenMillis);
            }

            counter.AddDeltaTime(FPSEvaluation.HICCUP_THRESHOLD_IN_SECONDS + 0.01f);

            Assert.AreEqual(counter.HiccupsCountInBuffer, 1);
        }
        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));
            }
        }
Пример #4
0
        private void Update()
        {
            var deltaInMs = Time.deltaTime * 1000;

            tracker.AddDeltaTime(Time.deltaTime);

            encodedSamples[currentIndex++] = (char)deltaInMs;
            if (currentIndex == SAMPLES_SIZE)
            {
                currentIndex = 0;
                Report(new string(encodedSamples));
                GenerateHiccupReport();
            }
        }
Пример #5
0
        public void BehavesLikeFPSCounter()
        {
            LinealBufferHiccupCounter counter = new LinealBufferHiccupCounter();

            const float tenMillis   = 0.01f;
            const float expectedFps = 100.0f;

            for (int i = 0; i < 100; i++)
            {
                counter.AddDeltaTime(tenMillis);
            }

            Assert.AreEqual(counter.CurrentFPSCount(), expectedFps);
        }
Пример #6
0
        public void CorrectlyAccountsTimeInHiccups()
        {
            LinealBufferHiccupCounter counter = new LinealBufferHiccupCounter();

            float hiccups     = 0.0f;
            int   hiccupCount = 0;

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

            Assert.AreEqual(counter.HiccupsSum, hiccups);
            Assert.AreEqual(counter.HiccupsCountInBuffer, hiccupCount);
        }