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
}
}

View File

@ -25,5 +25,11 @@
(2 1)
)
)
(dejong 1280 1.6 -2.3 2.4 -2.1)
(benchmark (lambda ()
(dejong 12800
(random -2 2)
(random -2 2)
(random -2 2)
(random -2 2)
)))
)