Ale*_*uin 30
您可以使用秒表来测量执行时间:
Stopwatch stopwatch = new Stopwatch()..start();
doSomething();
print('doSomething() executed in ${stopwatch.elapsed}');
Run Code Online (Sandbox Code Playgroud)
飞镖2:
new
final stopwatch = Stopwatch()..start();
doSomething();
print('doSomething() executed in ${stopwatch.elapsed}');
Run Code Online (Sandbox Code Playgroud)
在配置文件模式下使用开发工具以获得最佳结果
import 'dart:developer';
Timeline.startSync('interesting function');
// iWonderHowLongThisTakes();
Timeline.finishSync();
Run Code Online (Sandbox Code Playgroud)
https://flutter.dev/docs/testing/code-debugging#tracing-dart-code-performance
如果你在网上,你可以得到一个高分辨率的计时器:
num time = window.performance.now();
Run Code Online (Sandbox Code Playgroud)
来自http://api.dartlang.org/docs/releases/latest/dart_html/Performance.html#now
归档时间: |
|
查看次数: |
2949 次 |
最近记录: |