stopTiming static method

void stopTiming(
  1. String operation
)

Stop timing an operation and record the elapsed duration.

Implementation

static void stopTiming(String operation) {
  if (!ZenConfig.enablePerformanceMetrics || !_stopwatch.isRunning) return;

  _stopwatch.stop();
  final duration = _stopwatch.elapsed;
  final samples = _operationTimes.putIfAbsent(operation, () => []);
  samples.add(duration);

  // Keep only the 100 most recent samples to bound memory usage.
  if (samples.length > 100) {
    _operationTimes[operation] = samples.sublist(samples.length - 100);
  }
}