NativeScript Core

Fps Meter

Logging frames-per-second statistics for your app requires the fps-meter module.

Usage

Import FPS Meter Module

const fpsMeter = require("tns-core-modules/fps-meter");


let callbackId;
function startFPSMeter(args) {
    callbackId = fpsMeter.addCallback((fps, minFps) => {
        console.log(`Frames per seconds: ${fps.toFixed(2)}`);
        console.log(minFps.toFixed(2));
    });
    fpsMeter.start();
}

function stopFPSMeter(args) {
    fpsMeter.removeCallback(callbackId);
    fpsMeter.stop();
}
exports.startFPSMeter = startFPSMeter;
exports.stopFPSMeter = stopFPSMeter;
import { removeCallback, start, stop, addCallback } from "tns-core-modules/fps-meter";

let callbackId;
export function startFPSMeter(args) {
    callbackId = addCallback((fps: number, minFps: number) => {
        console.log(`Frames per seconds: ${fps.toFixed(2)}`);
        console.log(minFps.toFixed(2));
    });
    start();
}

export function stopFPSMeter(args) {
    removeCallback(callbackId);
    stop();
}

Improve this document

Demo Source


Methods

Name Type Description
addCallback(callback: function) number Adds a callback function to be called each time FPS data is due to be reported. Returns an unique id which can be used to remove this callback later.
removeCallback(id: number) any Removes the callback with the specified id.
running boolean Returns a valid indicating whether the frames-per-second meter is currently running.
start void Starts the frames-per-second meter.
stop void Stops the frames-per-second meter.

API References

Name Type
tns-core-modules/fps-meter Module

Native Component

Android iOS
android.view.Choreographer CADisplayLink