time method
void
time({
- String? debugLabel,
- String logPrefix = '',
- bool enabled = true,
- Duration? filterTime,
- LogFunction? log,
统计函数的执行时间
Implementation
void time({
String? debugLabel,
String logPrefix = '',
bool enabled = true,
Duration? filterTime,
LogFunction? log,
}) {
if (isRelease) {
this();
} else {
if (!enabled) {
this();
} else {
final stopwatch = Stopwatch()..start();
this();
stopwatch.stop();
final end = stopwatch.elapsedMicroseconds;
if (filterTime != null && filterTime.inMilliseconds > end / 1000) {
return;
}
if (end >= 1000) {
(log ?? logger.d)(
'$logPrefix耗时 ${(end / 1000).toStringAsFixed(2)} 毫秒',
debugLabel,
_logConfig,
);
} else {
(log ?? logger.d)('$logPrefix耗时 $end 微秒', debugLabel, _logConfig);
}
}
}
}