我有一个习惯来跟踪功能运行了多长时间,在react native
中,我可以将console.time
与react-native-console-time-polyfill一起使用
myFunction(){
console.time("Func Foo")
//any logic here
console.timeEnd("Func Foo")
}
如何使用Flutter做到这一点?
答案 0 :(得分:0)
答案 1 :(得分:0)
也许您可以尝试一下。
void main() async {
var dateTimeNow = DateTime.now();
await someExecution(); // call your function here.
var dateTimeAfterExecution = DateTime.now();
var difference = dateTimeAfterExecution.difference(dateTimeNow);
print(difference.inMilliseconds);
}
答案 2 :(得分:0)
尝试一下
myFunction(){
var oldTime = DateTime.now().millisecondsSinceEpoch;
//any logic here
// total time taken to run the logic would be
print("time = ${DateTime.now().millisecondsSinceEpoch - oldTime} ms");
}