NOTE! You are browsing legacy documentation. For latest visit docs.nativescript.org.

NativeScript Angular

Fps Meter

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

Usage

Import FPS Meter Module

import { Component, NgZone } from "@angular/core";
import { start, removeCallback, addCallback, stop } from "tns-core-modules/fps-meter";

@Component({
    moduleId: module.id,
    templateUrl: "./usage.component.html"
})
export class FpsMeterUsageComponent {
    public status = false;
    public callbackId;

    constructor(private zone: NgZone) { }

    startFPSMeter() {
        this.callbackId = addCallback((fps: number, minFps: number) => {
            this.zone.run(() => {
                console.log(`Frames per seconds: ${fps.toFixed(2)}`);
                console.log(minFps.toFixed(2));
            });
        });
        start();
    }

    stopFPSMeter() {
        removeCallback(this.callbackId);
        stop();
    }
}

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