Skip to content

Instantly share code, notes, and snippets.

@mr-pascal
Created February 7, 2021 06:32
Show Gist options
  • Save mr-pascal/ccc4b43137820ef04fea0bc844240177 to your computer and use it in GitHub Desktop.
Save mr-pascal/ccc4b43137820ef04fea0bc844240177 to your computer and use it in GitHub Desktop.
/**
* Measures the time in milliseconds it takes for the passed in method to finish
* @param {function} fn The method which should be measured
* @param {Array<unknown>} args A dynamic amount of parameters which will be passed into 'fn'
* @return {Promise<[unknown, number]>} A tuple where the first element is the response of the passed in method and the
* second the time in milliseconds it took to complete
*/
export declare const measureAsync: <T, G extends unknown[]>(fn: (...args: G) => Promise<T>, ...args: G) => Promise<[T, number]>;
/**
* Measures the time in milliseconds it takes for the passed in method to finish
* @param {function} fn The method which should be measured
* @param {Array<unknown>} args A dynamic amount of parameters which will be passed into 'fn'
* @return {[unknown, number]} A tuple where the first element is the response of the passed in method and the
* second the time in milliseconds it took to complete
*/
export declare const measureSync: <T, G extends unknown[]>(fn: (...args: G) => T, ...args: G) => [T, number];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment