< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ThrottlingCounter()0%110100%
EvaluateTimeBudget(...)0%330100%
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    {
 478        public bool enabled = true;
 312029        public double budgetPerFrame { get => enabled ? budgetPerFrameValue : double.MaxValue; set => budgetPerFrameValu
 4710        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        {
 627921            if ( elapsedTime <= 0 )
 202522                return false;
 23
 425424            timeBudgetCounter += elapsedTime;
 25
 425426            if ( timeBudgetCounter > budgetPerFrame )
 27            {
 14928                timeBudgetCounter = 0;
 14929                return true;
 30            }
 31
 410532            return false;
 33        }
 34
 35        public void Reset()
 36        {
 437            timeBudgetCounter = 0;
 438        }
 39    }
 40}