Fundamental Concepts
FPS Meter
FPS Meter allows you capture the frames-per-second metrics of your application.
Using FPS Meter β
Measuring FPS β
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
exportfunctionstartFPSMeter(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())
}
Stop measuring FPS β
Remove the registered callback using its id and then call the stop method.
exportfunctionstopFPSMeter(args:EventData) {
removeCallback(callbackId)
stop()
}
FPS Meter API β
addCallback β
constcallbackId=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 β
start()
Starts the frames-per-second meter.
stop β
stop()
Stops the frames-per-second meter.
removeCallback β
removeCallback(callbackId)
Removes the callback with the specified id.
running β
running()
Returns a boolean value indicating whether the frames-per-second meter is currently running.
Additional Resources β
Native Component β
- Android: android.view.Choreographer
- iOS: CADisplayLink
- Previous
- FileSystem
- Next
- Http
Contributors
Last updated: