page-fps
Inject fps indicator into your page.
Install
npm i --save page-fps
Usage
- Code usage
import PF from 'page-fps';
const pf = new PF();
// start
pf.start();
// stop
pf.stop();
- Script usage
Just import dist/entry.min.js
into your document with script tag.
API
import PF from 'page-fps';
import { FPS, Timer } from 'page-fps'
-
PF
: page fps indicator. -
FPS
: a fps collector.
import { FPS } from 'page-fps';
const fps = new FPS();
// 开始记录数据
fps.start();
// 计算当前 fps
const f = fps.sample();
// 停止记录数据
fps.stop();
Timer
: a callback execute timer.
import { Timer } from 'page-fps';
const timer = new Timer(callback, 30);
// 每隔 30ms 执行一次 callback 方法
timer.start();
// 停止
timer.stop();
License
MIT