framerate-history
v1.0.18
Published
An ES6 class for tracking framerate for a given period of time.
Downloads
58
Readme
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 |
frameRate.fps ⇒ Number 🔒 Read only
The last recorded FPS
frameRate.history ⇒ Array 🔒 Read only
The FPS recordings over the history duration
frameRate.filterStrength([value]) ⇒ Number 🔗 Chainable
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 |
frameRate.sampleRate([value]) ⇒ Number 🔗 Chainable
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 |
frameRate.onSample([callback]) ⇒ function 🔗 Chainable
The callback will get called for every sample taken.
| Param | Type | Description | | --- | --- | --- | | [callback] | function | The callback is given one param, the FPS history array. |
frameRate.historyDuration([value]) ⇒ Number 🔗 Chainable
Defines the duration of tracked history.
Default: 30
| Param | Type | Description | | --- | --- | --- | | [value] | Number | Seconds |