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

    Function timeInternal

    Executes a task (sync or async) and monitors its execution 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

      Any error thrown by the task (monitor is not called on error)

    • 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

      Any error thrown by the task (monitor is not called on error)