title |
---|
FPS Meter |
FPS Meter allows you capture the frames-per-second metrics of your application.
Register a callback that will receive the FPS metrics using the addCallBack method. Then call the start method to begin measuring.
import {
removeCallback,
start,
stop,
addCallback,
running,
} from '@nativescript/core/fps-meter'
let callbackId: number
export function startFPSMeter(args: EventData) {
callbackId = addCallback((fps: number, minFps: number | undefined) => {
console.log(`Frames per seconds: ${fps.toFixed(2)}`)
console.log(minFps?.toFixed(2))
})
start()
console.log('Is running: ', running())
}
Remove the registered callback using its id and then call the stop method.
export function stopFPSMeter(args: EventData) {
removeCallback(callbackId)
stop()
}
const callbackId = addCallback(callback: (fps: number, minFps?: number) => void): number
Implement a callback function that will be executed whenever FPS data becomes available. Assign a unique identifier (number
) to this callback, facilitating its future removal, if needed.
start()
Starts the frames-per-second meter.
stop()
Stops the frames-per-second meter.
removeCallback(callbackId)
Removes the callback with the specified id.
running()
Returns a boolean value indicating whether the frames-per-second meter is currently running.
- Android: android.view.Choreographer
- iOS: CADisplayLink