add benchmark function

This commit is contained in:
Quentin Leonetti
2019-07-18 12:16:24 +02:00
parent e8713f34ae
commit ad941de3a1
2 changed files with 14 additions and 1 deletions

View File

@@ -347,4 +347,11 @@ function Library (ronin) {
}
return a === b
}
this.benchmark = async (fn) => { // logs time taken to execute a function
const start = Date.now()
const result = await fn()
console.log(`time taken: ${Date.now() - start}ms`)
return result
}
}