我有习惯跟踪我的功能运行多长时间,在react native
我可以使用console.time
和react-native-console-time-polyfill
myFunction(){
console.time("Func Foo")
//any logic here
console.timeEnd("Func Foo")
}
我怎么能用Flutter做到这一点?
也许你可以尝试这个..
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);
}
试试这个
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");
}