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


You can use this:

void functionToBeTested() async {

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

//your logic here

print('time elapsed ${stopwatch.elapsed}');
Feroz Khan
Author by

Feroz Khan

Feroz Khan 26-year-old guy working at Upgenics International as Executive Software Engineer. More Info Skills: • Android Development (Native) • Having Experience in User Interface (UI), User Experience (UX). • Android Architecture Components (JetPack) with MVVM design pattern. • Great experience in Google Maps Integration, Google Maps API and Facebook API. • Strong experience with Rest APIs using Retrofit and Volley Frameworks and Background Services • Strong experience in PHP Laravel Framework.

Updated on December 31, 2022


  • Feroz Khan
    Feroz Khan 5 months

    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.