Created
July 25, 2014 11:44
-
-
Save ShigekiKarita/f51bb6b7e4511e91675e to your computer and use it in GitHub Desktop.
simple stopwatch in JavaScript 1.8
This file contains hidden or 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
// for Firefox 31 | |
const time = (process, n=1) => | |
{ | |
let total = 0.0; | |
for (let i = 0; i < n; ++i) | |
{ | |
const start = window.performance.now(); | |
process(); | |
const elapsed = window.performance.now() - start; | |
total += elapsed / n; | |
} | |
console.log(total); | |
}; | |
// how to use | |
const fib = (i, n = i) => i > 0 ? fib(i - 1, n + i - 1) : n; | |
time(_=> fib(6000) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment