refactor: disable benchmarks by global boolean (#2104)

Benchmarks are flooding the logs. We should disable them by default and allow having low debug level at the same time.
This commit is contained in:
Krille-chan 2025-06-06 13:45:13 +02:00 committed by GitHub
parent a3da3bda77
commit 6cf6171b35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -18,6 +18,8 @@
import 'package:matrix/matrix.dart'; import 'package:matrix/matrix.dart';
var kEnableMatrixSdkBenchmarks = false;
/// Calculates some benchmarks for this function. Give it a [name] and a [func] /// Calculates some benchmarks for this function. Give it a [name] and a [func]
/// to call and it will calculate the needed milliseconds. Give it an optional /// to call and it will calculate the needed milliseconds. Give it an optional
/// [itemCount] to let it also calculate the needed milliseconds per item. /// [itemCount] to let it also calculate the needed milliseconds per item.
@ -26,7 +28,7 @@ Future<T> runBenchmarked<T>(
Future<T> Function() func, [ Future<T> Function() func, [
int? itemCount, int? itemCount,
]) async { ]) async {
if (Logs().level.index < Level.debug.index) { if (!kEnableMatrixSdkBenchmarks) {
return func(); return func();
} }
final start = DateTime.now(); final start = DateTime.now();