< Summary

Information
Class: Trailblazer.Pathing.GuideSampleWorkMeter
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/Flow/GuideSampleWorkMeter.cs
Line coverage
100%
Covered lines: 24
Uncovered lines: 0
Coverable lines: 24
Total lines: 75
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/Flow/GuideSampleWorkMeter.cs

#LineLine coverage
 1//=======================================================================
 2// GuideSampleWorkMeter.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8namespace Trailblazer.Pathing;
 9
 10/// <summary>Tracks exact bounded work shared by one or more guide samples.</summary>
 11internal struct GuideSampleWorkMeter
 12{
 13    private int _remainingCurrentNodeLookupProbes;
 14    private int _remainingCursorLegScans;
 15    private int _remainingCursorRebases;
 16    private int _remainingPortalChecks;
 17    private int _remainingPrismChecks;
 18    private int _remainingTraceIntervals;
 19    private int _remainingLocalRecoveryAttempts;
 20
 21    internal GuideSampleWorkMeter(GuideSampleWorkBudget budget)
 22    {
 169423        _remainingCurrentNodeLookupProbes = budget.MaxCurrentNodeLookupProbes;
 169424        _remainingCursorLegScans = budget.MaxCursorLegScans;
 169425        _remainingCursorRebases = budget.MaxCursorRebases;
 169426        _remainingPortalChecks = budget.MaxPortalChecks;
 169427        _remainingPrismChecks = budget.MaxPrismChecks;
 169428        _remainingTraceIntervals = budget.MaxTraceIntervals;
 169429        _remainingLocalRecoveryAttempts = budget.MaxLocalRecoveryAttempts;
 169430    }
 31
 32    internal bool TryConsumeCurrentNodeLookupProbes(int count) =>
 1462533        TryConsume(ref _remainingCurrentNodeLookupProbes, count);
 34
 35    internal bool TryConsumeCursorLegScans(int count) =>
 349236        TryConsume(ref _remainingCursorLegScans, count);
 37
 38    internal bool TryConsumeCursorRebases(int count) =>
 86739        TryConsume(ref _remainingCursorRebases, count);
 40
 41    internal bool TryConsumePortalChecks(int count) =>
 393942        TryConsume(ref _remainingPortalChecks, count);
 43
 44    internal bool TryConsumePrismChecks(int count) =>
 604345        TryConsume(ref _remainingPrismChecks, count);
 46
 47    internal bool TryConsumeTraceIntervals(int count) =>
 109148        TryConsume(ref _remainingTraceIntervals, count);
 49
 50    internal bool TryConsumeLocalRecoveryAttempts(int count) =>
 85751        TryConsume(ref _remainingLocalRecoveryAttempts, count);
 52
 53    internal readonly int GetCurrentNodeLookupAllowance() =>
 589654        _remainingCurrentNodeLookupProbes;
 55
 56    internal readonly int GetTraceIntervalAllowance() =>
 74457        _remainingTraceIntervals;
 58
 59    internal readonly int GetCursorLegScanAllowance() =>
 12360        _remainingCursorLegScans;
 61
 62    internal readonly int GetPortalCheckAllowance() =>
 12163        _remainingPortalChecks;
 64
 65    internal readonly int GetPrismCheckAllowance() =>
 12266        _remainingPrismChecks;
 67
 68    private static bool TryConsume(ref int remaining, int count)
 69    {
 3091470        if (count > remaining)
 8471            return false;
 3083072        remaining -= count;
 3083073        return true;
 74    }
 75}