FpsService class
FPS 监控服务 / FPS monitoring service
通过 WidgetsBinding.instance.addTimingsCallback 采集帧数据,
Collects frame data via WidgetsBinding.instance.addTimingsCallback,
提供实时 FPS 计算、帧耗时统计、掉帧检测功能。
Provides real-time FPS calculation, frame duration stats, and jank detection.
使用方式 / Usage:
// 启动 FPS 监控 / Start FPS monitoring
FpsService.instance.start();
// 获取当前 FPS / Get current FPS
double currentFps = FpsService.instance.currentFps;
// 关闭 FPS 监控 / Stop FPS monitoring
FpsService.instance.stop();
- Inheritance
-
- Object
- ChangeNotifier
- FpsService
Properties
- currentFps → double
-
当前 FPS / Current FPS
no setter
-
fpsHistory
→ List<
double> -
最近 FPS 历史值(60个)/ Recent FPS history values (60 entries)
no setter
-
frameRecords
→ List<
FrameRecord> -
最近帧记录列表 / Recent frame record list
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isIdle → bool
-
获取是否空闲(无动画/无渲染时为真,此时低 FPS 不算性能问题)
Get whether idle (true when no animation/render; low FPS then is not a perf problem)
no setter
- isRunning → bool
-
是否正在监控 / Whether monitoring is active
no setter
- jankRate → double
-
掉帧率(百分比)/ Jank rate (percentage)
no setter
- jankThresholdUs → int
-
公开的自适应掉帧阈值(微秒)/ Public adaptive jank threshold (microseconds)
no setter
- lastFrameJanky → bool
-
最近一帧是否掉帧 / Whether the most recent frame is janky
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- totalFrameCount → int
-
累计总帧数 / Total frame count
no setter
- totalJankyCount → int
-
累计掉帧数 / Total janky frame count
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
clear(
) → void - 清空历史数据 / Clear historical data
-
dispose(
) → void -
Discards any resources used by the object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
start(
) → void - 启动 FPS 监控 / Start FPS monitoring
-
stop(
) → void - 停止 FPS 监控 / Stop FPS monitoring
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → FpsService
-
单例实例 / Singleton instance
final