Created
February 24, 2017 14:01
-
-
Save xaviervia/c3ef5a1e470fac3d60b7a172c2736b1e to your computer and use it in GitHub Desktop.
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
window.profileSTandRAF = () => { | |
let end = false | |
let setTimeoutCount = 0 | |
let requestAnimationFrameCount = 0 | |
setTimeout(() => { end = true }, 2000) | |
const setTimeoutLoop = () => { | |
setTimeoutCount = setTimeoutCount + 1 | |
if (!end) { | |
console.log('setTimeout count', setTimeoutCount) | |
setTimeout(setTimeoutLoop) | |
} else { | |
console.log('setTimeout total', setTimeoutCount) | |
} | |
} | |
const requestAnimationFrameLoop = () => { | |
requestAnimationFrameCount = requestAnimationFrameCount + 1 | |
if (!end) { | |
console.log('requestAnimationFrame count', requestAnimationFrameCount) | |
requestAnimationFrame(requestAnimationFrameLoop) | |
} else { | |
console.log('requestAnimationFrame total', requestAnimationFrameCount) | |
} | |
} | |
setTimeout(() => { | |
setTimeoutLoop() | |
requestAnimationFrameLoop() | |
}, 1000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment