Skip to content

Commit

Permalink
FrameTimeCapBudget to ulong (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickKhalow authored Jan 10, 2024
1 parent 8a5ff30 commit 6c274c3
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
using DCL.Profiling;
using System;

namespace DCL.Optimization.PerformanceBudgeting
{
public class FrameTimeCapBudget : IPerformanceBudget
{
private readonly ulong totalBudgetAvailable;
private readonly IProfilingProvider profilingProvider;
private readonly float totalBudgetAvailable;

public FrameTimeCapBudget(float budgetCapInMS, IProfilingProvider profilingProvider)
public FrameTimeCapBudget(float budgetCapInMS, IProfilingProvider profilingProvider) : this(
TimeSpan.FromMilliseconds(budgetCapInMS),
profilingProvider
) { }

public FrameTimeCapBudget(TimeSpan totalBudgetAvailable, IProfilingProvider profilingProvider) : this(
Convert.ToUInt64(
totalBudgetAvailable.TotalMilliseconds * 1000000 //converting milliseconds to nanoseconds
),
profilingProvider
) { }

public FrameTimeCapBudget(ulong totalBudgetAvailable, IProfilingProvider profilingProvider)
{
//FrameTime return CurrentValue in nanoseconds, so we are converting milliseconds to nanoseconds
totalBudgetAvailable = budgetCapInMS * 1000000;
this.profilingProvider = profilingProvider;
this.totalBudgetAvailable = totalBudgetAvailable;
}

public bool TrySpendBudget() =>
Expand Down

0 comments on commit 6c274c3

Please sign in to comment.