measure<T> method
Implementation
Future<T> measure<T>(
String label,
Future<T> Function() task,
) async {
if (!kDebugMode) {
return task();
}
final stopwatch = Stopwatch()..start();
try {
log('$label started.');
final result = await task();
stopwatch.stop();
log('$label completed in ${stopwatch.elapsedMilliseconds}ms.');
return result;
} catch (e) {
stopwatch.stop();
log('$label failed in ${stopwatch.elapsedMilliseconds}ms.');
rethrow;
}
}