@metreeca/core - v0.9.7
    Preparing search index...

    Function time

    • Executes an asynchronous task and monitors its execution time.

      Measures elapsed time from invocation until promise resolution.

      Type Parameters

      • T

        The type of value returned by the task

      Parameters

      • task: () => Promise<T>

        Function returning a promise to be timed

      • monitor: (value: T, elapsed: number) => void

        Callback invoked with the result value and elapsed time in milliseconds

      Returns Promise<T>

      A promise resolving to the task's return value

    • Executes a synchronous task and monitors its execution time.

      Measures elapsed time from invocation until completion.

      Type Parameters

      • T

        The type of value returned by the task

      Parameters

      • task: () => T

        Function returning a value to be timed

      • monitor: (value: T, elapsed: number) => void

        Callback invoked with the result value and elapsed time in milliseconds

      Returns T

      The task's return value