time

Measures the duration of an operation and returns the result along with the elapsed time in milliseconds.

Usage

import { time } from "@olenbetong/appframe-core";

let [value, elapsed] = await time(async () => {
// ...
return 42;
});

API

export declare function time<T>(callback: () => T | Promise<T>): Promise<[T, number]>;

Last updated

Was this helpful?