📺 "One project. One language. Three apps." Learn more in our upcoming code sharing webinar!

NativeScript Core

Fps Meter

"fps-meter" module allows to logging frames-per-second statistics for the app.

const fpsMeter = require("tns-core-modules/fps-meter");
import { removeCallback, start, stop, addCallback } from "tns-core-modules/fps-meter";

Basics

The example demonstrates how the fps-meter could be required and how to access the data provided by the module.

Add Callback method and start logging

callbackId = fpsMeter.addCallback((fps, minFps) => {
        vm.set("fps", fps.toFixed(2));
        vm.set("minfps", minFps.toFixed(2));
});

fpsMeter.start();
callbackId = addCallback((fps, minFps) => {
    vm.set("fps", fps.toFixed(2));
    vm.set("minfps", minFps.toFixed(2));
});

start();

Remove Callback method and stop logging

fpsMeter.removeCallback(callbackId);
fpsMeter.stop();
removeCallback(callbackId);
stop();

Improve this document

Demo Source


API Reference for the FPS Meter Class