Class DpsWindow

Namespace
SurvivorsMaker.Presentation
Assembly
SurvivorsMaker.Presentation.dll

Sliding sum over the last WindowTicks ticks per key: one bucket per tick in a ring, so adding is O(1) and nothing is allocated after a key is first seen. Rates divide by the window, or by the ticks since StartTick while fewer have passed (so the first second of a wave is not under-reported).

public sealed class DpsWindow
Inheritance
DpsWindow
Inherited Members

Constructors

DpsWindow(int)

public DpsWindow(int windowTicks)

Parameters

windowTicks int

Properties

Keys

Keys in the order first seen.

public IReadOnlyList<int> Keys { get; }

Property Value

IReadOnlyList<int>

StartTick

public int StartTick { get; }

Property Value

int

WindowTicks

public int WindowTicks { get; }

Property Value

int

Methods

Add(int, int, float)

public void Add(int tick, int key, float amount)

Parameters

tick int
key int
amount float

PerSecond(float, int, float)

public float PerSecond(float sum, int nowTick, float tickSeconds)

Parameters

sum float
nowTick int
tickSeconds float

Returns

float

Rate(int, int, float)

public float Rate(int key, int nowTick, float tickSeconds)

Parameters

key int
nowTick int
tickSeconds float

Returns

float

Reset(int)

Forgets every amount; keys stay known. Ticks before startTick are never counted.

public void Reset(int startTick)

Parameters

startTick int

Share(int, int)

Fraction 0–1 of the window's total that came from key.

public float Share(int key, int nowTick)

Parameters

key int
nowTick int

Returns

float

SpanTicks(int)

Ticks the rate is measured over: the window, or fewer at the start.

public int SpanTicks(int nowTick)

Parameters

nowTick int

Returns

int

Sum(int, int)

Amount added for key in the window ending at nowTick (inclusive).

public float Sum(int key, int nowTick)

Parameters

key int
nowTick int

Returns

float

Total(int)

public float Total(int nowTick)

Parameters

nowTick int

Returns

float

TotalRate(int, float)

public float TotalRate(int nowTick, float tickSeconds)

Parameters

nowTick int
tickSeconds float

Returns

float