Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrameTimeCapBudget to ulong #252

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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