perfMeasure<T> function

T perfMeasure<T>(
  1. String name,
  2. T fn()
)

Wraps fn with timing and logs the result.

Implementation

T perfMeasure<T>(String name, T Function() fn) {
  if (!_enabled) return fn();
  final stopwatch = Stopwatch()..start();
  try {
    return fn();
  } finally {
    stopwatch.stop();
    perfLog(name, stopwatch.elapsedMicroseconds);
  }
}