@univerjs/engine-render v0.5.0-beta.1 • Docs
Class: RollingAverage
RollingAverage
Utility to efficiently compute the rolling average and variance over a sliding window of samples
Constructors
new RollingAverage()
new RollingAverage(length): RollingAverage
constructor
Parameters
Parameter | Type | Description |
---|---|---|
length | number | The number of samples required to saturate the sliding window |
Returns
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:246
Properties
Property | Modifier | Type | Default value | Description | Defined in |
---|---|---|---|---|---|
_m2 | protected | number | 0 | - | packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:240 |
_pos | protected | number | 0 | - | packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:239 |
_sampleCount | protected | number | 0 | for isStaturated max value of _sampleCount is length of _samples | packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:238 |
_samples | protected | number [] | [] | - | packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:232 |
averageFrameTime | public | number | DEFAULT_FRAME_TIME | Current average | packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:226 |
variance | public | number | 0 | Current variance | packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:231 |
Methods
_wrapPosition()
protected _wrapPosition(i): number
Wraps a value around the sample range boundaries
Parameters
Parameter | Type | Description |
---|---|---|
i | number | Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned. |
Returns
number
Wrapped position in sample range
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:330
addFrameTime()
addFrameTime(frameTime): void
Adds a sample to the sample set
Parameters
Parameter | Type | Description |
---|---|---|
frameTime | number | The sample value |
Returns
void
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:286
calcAverageFrameTime()
calcAverageFrameTime(): void
Calc average frameTime and variance.
Returns
void
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:254
history()
history(i): number
Returns previously added values or null if outside of history or outside the sliding window domain
Parameters
Parameter | Type | Description |
---|---|---|
i | number | Index in history. For example, pass 0 for the most recent value and 1 for the value before that |
Returns
number
Value previously recorded with add() or null if outside of range
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:297
isSaturated()
isSaturated(): boolean
Returns true if enough samples have been taken to completely fill the sliding window
Returns
boolean
true if sample-set saturated
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:310
reset()
reset(): void
Resets the rolling average (equivalent to 0 samples taken so far)
Returns
void
Defined in
packages/api/tmp/univer-pro/submodules/univer/packages/engine-render/src/basics/performance-monitor.ts:317