framerate-history

1.0.18 • Public • Published

Framerate History

An ES6 class for tracking framerate for a given period of time.

npm deps size vulnerabilities license


Installation

npm install framerate-history


FrameRate

import FrameRate from 'framerate-history';


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

Readme

Keywords

Package Sidebar

Install

npm i framerate-history

Weekly Downloads

16

Version

1.0.18

License

MIT

Unpacked Size

11.8 kB

Total Files

4

Last publish

Collaborators

  • darrenpaulwright