A frames-per-seconds measurer and GUI control
- class
FPSMeasurer
- An non-dependent class for measuring FPS and calculating stats. - class
FPSControl
- A MapBox GL GUI Control
var fpsControl = new MapboxFPS.FPSControl();
myMap.addControl(fpsControl, 'top-right');
setTimeout(function(){
var report = fpsControl.measurer.getMeasurementsReport();
console.log('Report:', report);
}, 10000)
var fpsMeasurer = new MapboxFPS.FPSMeasurer();
fpsMeasurer.startMeasuring();
// Measure 'mock render frames' every 20 ms for 2 seconds
var interval = setInterval( () => { measurer.registerRenderFrame() }, 20);
setTimeout( () => {
// Stop the mock frame render interval
clearInterval(interval);
// Stop measuring
fpsMeasurer.startMeasuring();
// Generate report
var report = measurer.getMeasurementsReport();
console.log('Report: ', report);
}, 2000);
var fpsMeasurer = new MapboxFPS.FPSMeasurer();
var report = measurer.getMeasurementsReport();
returns an object:
// generated report
{
"measurements": [...], // Array of actual measurements done
"median": Number,
"average": Number,
"variance": Number,
"stdDev": Number
}