timed<T> static method

Future<TimedResult<T?>> timed<T>(
  1. FutureOr<T> exec, {
  2. String? debugName,
})

Implementation

static Future<TimedResult<T?>> timed<T>(FutureOr<T> exec,
    {String? debugName}) async {
  final start = DateTime.now();
  final value = await exec;
  try {
    return TimedResult<T>(value, ResultType.success, null, start.sinceNow(),
        debugName: debugName);
  } catch (e) {
    return TimedResult<T?>(null, ResultType.error, "$e", start.sinceNow(),
        debugName: debugName);
  }
}