πŸš€ 8.9 Released! β†’ ⚑️ New Node-API Engine Preview, πŸ“² ns widget ios, πŸ’… Tailwind v4 and more...
Read Announcement

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.

ts
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.

ts
exportfunctionstopFPSMeter(args:EventData) {
removeCallback(callbackId)

stop()
}

FPS Meter API ​

addCallback ​

ts
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 ​

ts
start()

Starts the frames-per-second meter.


stop ​

ts
stop()

Stops the frames-per-second meter.


removeCallback ​

ts
removeCallback(callbackId)

Removes the callback with the specified id.


running ​

ts
running()

Returns a boolean value indicating whether the frames-per-second meter is currently running.


Additional Resources ​

Native Component ​

Previous
FileSystem
Next
Http

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /