time method
void
time({
- String? debugLabel,
- String logPrefix = '',
- bool enabled = true,
- Duration? filterTime,
- ElLogFunction? log,
统计函数的执行时间
Implementation
void time({
String? debugLabel,
String logPrefix = '',
bool enabled = true,
Duration? filterTime,
ElLogFunction? log,
}) {
if (El.kReleaseMode) {
// coverage:ignore-line
this(); // coverage:ignore-line
} 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) {
// coverage:ignore-line
(log ?? El.d)(
'$logPrefix耗时 ${(end / 1000).toStringAsFixed(2)} 毫秒',
title: debugLabel,
config: _logConfig,
); // coverage:ignore-line
} else {
(log ?? El.d)('$logPrefix耗时 $end 微秒', title: debugLabel, config: _logConfig);
}
}
}
}