timeAsyncOperation function

Future<Duration> timeAsyncOperation(
  1. Future<void> operation()
)

Times the specified asynchronous operation.

Implementation

Future<Duration> timeAsyncOperation(Future<void> Function() operation) async {
  var stopwatch = Stopwatch()..start();
  await operation();
  return stopwatch.elapsed;
}