Created
October 22, 2020 14:57
-
-
Save neenjaw/e61dc04cd59483a993798fbb7da958bd to your computer and use it in GitHub Desktop.
Simple typescript benchmarker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const wrapBenchmark = ( | |
fn: (...args: any[]) => any, | |
label?: string | |
): ((...args: any[]) => any) => { | |
return (...args) => { | |
const start = Date.now() | |
const result = fn.apply(null, args) | |
const end = Date.now() | |
console.info(`📈 BENCHMARK${label ? ` ${label}` : ''} ${end - start}ms`) | |
return result | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment