measureAsync<T> static method
Implementation
static Future<T> measureAsync<T>(
String name,
Future<T> Function() operation,
) async {
final stopwatch = Stopwatch()..start();
try {
final result = await operation();
stopwatch.stop();
DKLog.i(
'$name 耗时: ${stopwatch.elapsedMilliseconds}ms',
tag: 'Performance',
);
return result;
} catch (e) {
stopwatch.stop();
DKLog.e(
'$name 失败,耗时: ${stopwatch.elapsedMilliseconds}ms',
tag: 'Performance',
error: e,
);
rethrow;
}
}