< Summary

Class:DCL.ThrottlingCounter
Assembly:CoroutineHelpers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/CoroutineHelpers/ThrottlingCounter.cs
Covered lines:9
Uncovered lines:3
Coverable lines:12
Total lines:40
Line coverage:75% (9 of 12)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ThrottlingCounter()0%110100%
EvaluateTimeBudget(...)0%3.033085.71%
Reset()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/CoroutineHelpers/ThrottlingCounter.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4namespace DCL
 5{
 6    public class ThrottlingCounter
 7    {
 438        public bool enabled = true;
 30469        public double budgetPerFrame { get => enabled ? budgetPerFrameValue : double.MaxValue; set => budgetPerFrameValu
 4310        private double budgetPerFrameValue = 2 / 1000.0;
 11        private double timeBudgetCounter = 0f;
 12
 13        /// <summary>
 14        /// EvaluateTimeBudget decrements an internal time budget counter according to the given elapsedTime.
 15        /// The method returns a bool value indicating that the time budget has been exceeded. When this happens, a fram
 16        /// </summary>
 17        /// <param name="elapsedTime">The elapsed time in seconds.</param>
 18        /// <returns>True if a frame skip is needed</returns>
 19        public bool EvaluateTimeBudget(double elapsedTime)
 20        {
 304621            if ( elapsedTime <= 0 )
 022                return false;
 23
 304624            timeBudgetCounter += elapsedTime;
 25
 304626            if ( timeBudgetCounter > budgetPerFrame )
 27            {
 18228                timeBudgetCounter = 0;
 18229                return true;
 30            }
 31
 286432            return false;
 33        }
 34
 35        public void Reset()
 36        {
 037            timeBudgetCounter = 0;
 038        }
 39    }
 40}