@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
110 lines (109 loc) • 3.55 kB
TypeScript
/**
* Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
*/
export declare class PerformanceMonitor {
private _enabled;
private _rollingFrameTime;
private _lastFrameTimeMs;
/**
* constructor
* @param frameSampleSize The number of samples required to saturate the sliding window
*/
constructor(frameSampleSize?: number);
/**
* Samples current frame
* @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
*/
sampleFrame(timeMs?: number): void;
/**
* Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
*/
get averageFrameTime(): number;
/**
* Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
*/
get averageFrameTimeVariance(): number;
/**
* Returns the frame time of the most recent frame
*/
get instantaneousFrameTime(): number;
/**
* Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
*/
get averageFPS(): number;
/**
* Returns the average framerate in frames per second using the most recent frame time
*/
get instantaneousFPS(): number;
/**
* Returns true if enough samples have been taken to completely fill the sliding window
*/
get isSaturated(): boolean;
/**
* Enables contributions to the sliding window sample set
*/
enable(): void;
/**
* Disables contributions to the sliding window sample set
* Samples will not be interpolated over the disabled period
*/
disable(): void;
/**
* Returns true if sampling is enabled
*/
get isEnabled(): boolean;
/**
* Resets performance monitor
*/
reset(): void;
}
/**
* RollingAverage
*
* Utility to efficiently compute the rolling average and variance over a sliding window of samples
*/
export declare class RollingAverage {
/**
* Current average
*/
average: number;
/**
* Current variance
*/
variance: number;
protected _samples: Array<number>;
protected _sampleCount: number;
protected _pos: number;
protected _m2: number;
/**
* constructor
* @param length The number of samples required to saturate the sliding window
*/
constructor(length: number);
/**
* Adds a sample to the sample set
* @param v The sample value
*/
add(v: number): void;
/**
* Returns previously added values or null if outside of history or outside the sliding window domain
* @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
* @returns Value previously recorded with add() or null if outside of range
*/
history(i: number): number;
/**
* Returns true if enough samples have been taken to completely fill the sliding window
* @returns true if sample-set saturated
*/
isSaturated(): boolean;
/**
* Resets the rolling average (equivalent to 0 samples taken so far)
*/
reset(): void;
/**
* Wraps a value around the sample range boundaries
* @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
* @returns Wrapped position in sample range
*/
protected _wrapPosition(i: number): number;
}