Skip to content

Instantly share code, notes, and snippets.

@neenjaw
Created October 22, 2020 14:57
Show Gist options
  • Save neenjaw/e61dc04cd59483a993798fbb7da958bd to your computer and use it in GitHub Desktop.
Save neenjaw/e61dc04cd59483a993798fbb7da958bd to your computer and use it in GitHub Desktop.
Simple typescript benchmarker
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