timeHandler function

Future timeHandler(
  1. FutureOr fn()
)

Not exported. Runs the controller fn and adds its time as handler, also when it throws. Call it only when serverTimingOn.

Implementation

Future<dynamic> timeHandler(FutureOr<dynamic> Function() fn) async {
  _Timings timings = Zone.current[ServerTiming._key] as _Timings;
  Stopwatch watch = Stopwatch()..start();
  try {
    return await fn();
  } finally {
    timings.add('handler', watch.elapsed, null, own: true);
  }
}