Framerate History
An ES6 class for tracking framerate for a given period of time.
Installation
npm install framerate-history
FrameRate
import FrameRate from 'framerate-history';
-
FrameRate
- new FrameRate(settings)
-
.fps ⇒
Number
-
.history ⇒
Array
-
.filterStrength([value]) ⇒
Number
-
.sampleRate([value]) ⇒
Number
-
.onSample([callback]) ⇒
function
-
.historyDuration([value]) ⇒
Number
new FrameRate(settings)
Param | Type | Default |
---|---|---|
settings | Object |
|
[settings.onSample] | function |
|
[settings.filterStrength] | Number |
5 |
[settings.historyDuration] | Number |
30 |
[settings.sampleRate] | Number |
10 |
Number
🔒 Read only
frameRate.fps ⇒ The last recorded FPS
Array
🔒 Read only
frameRate.history ⇒ The FPS recordings over the history duration
Number
🔗 Chainable
frameRate.filterStrength([value]) ⇒ Sets a filter on the frame rate calculation. Setting to 1 will effectively turn off the filter, the higher the number the more smooth the curve over time. See this stackoverflow question for details: https://stackoverflow.com/questions/4787431/check-fps-in-js
Default: 5
Param | Type |
---|---|
[value] | Number |
Number
🔗 Chainable
frameRate.sampleRate([value]) ⇒ The rate to take samples. Setting to 0 will clear the interval. If the interval is prevented from executing at the desired rate, the history will get filled in with the current frame rate in an attempt to keep the history as accurate as possible.
Default: 10
Param | Type | Description |
---|---|---|
[value] | Number |
Samples per second |
function
🔗 Chainable
frameRate.onSample([callback]) ⇒ The callback will get called for every sample taken.
Param | Type | Description |
---|---|---|
[callback] | function |
The callback is given one param, the FPS history array. |
Number
🔗 Chainable
frameRate.historyDuration([value]) ⇒ Defines the duration of tracked history.
Default: 30
Param | Type | Description |
---|---|---|
[value] | Number |
Seconds |