优化录制页性能
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
Future<T> measureRecordingOperation<T>(
|
||||
String label,
|
||||
Future<T> Function() operation,
|
||||
) async {
|
||||
if (kReleaseMode) {
|
||||
return operation();
|
||||
}
|
||||
|
||||
final stopwatch = Stopwatch()..start();
|
||||
try {
|
||||
return await operation();
|
||||
} finally {
|
||||
stopwatch.stop();
|
||||
debugPrint(
|
||||
'[RecordingPerformance] $label: ${stopwatch.elapsedMilliseconds}ms',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void logRecordingPerformance(String label, Duration elapsed) {
|
||||
if (kReleaseMode) return;
|
||||
debugPrint('[RecordingPerformance] $label: ${elapsed.inMilliseconds}ms');
|
||||
}
|
||||
Reference in New Issue
Block a user