< Summary

Class:DCL.ThrottlingCounter
Assembly:CoroutineHelpers
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/CoroutineHelpers/ThrottlingCounter.cs
Covered lines:11
Uncovered lines:1
Coverable lines:12
Total lines:40
Line coverage:91.6% (11 of 12)
Covered branches:0
Total branches:0
Covered methods:5
Total methods:5
Method coverage:100% (5 of 5)

Metrics

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

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    {
 148        public bool enabled = true;
 30249        public double budgetPerFrame { get => enabled ? budgetPerFrameValue : double.MaxValue; set => budgetPerFrameValu
 1410        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        {
 302021            if ( elapsedTime <= 0 )
 022                return false;
 23
 302024            timeBudgetCounter += elapsedTime;
 25
 302026            if ( timeBudgetCounter > budgetPerFrame )
 27            {
 16728                timeBudgetCounter = 0;
 16729                return true;
 30            }
 31
 285332            return false;
 33        }
 34
 35        public void Reset()
 36        {
 437            timeBudgetCounter = 0;
 438        }
 39    }
 40}