measureTimedValue<T> function

TimedValue<T> measureTimedValue<T>(
  1. T block()
)

Executes the given function block and returns an instance of TimedValue class, containing both the result of the function execution and the duration of elapsed time interval.

Implementation

TimedValue<T> measureTimedValue<T>(T Function() block) {
  final start = DateTime.now();
  final value = block();
  return (DateTime.now().difference(start), value);
}