How to test execution time of an async method returning Future in Flutter

Viewed 814

I'm working on someone's Flutter code and there are many methods on a single dart screen file. They are loading data from the backend API and taking too long. So, I want to calculate the execution time for each of those async methods so to optimize the code for better performance.

1 Answers

You can use this:

void functionToBeTested() async {

Stopwatch stopwatch = Stopwatch()..start();

//your logic here

stopwatch.stop();
print('time elapsed ${stopwatch.elapsed}');
}
Related