Last active
August 30, 2015 02:15
-
-
Save pingyen/76686 to your computer and use it in GitHub Desktop.
JavaScript Function Call Performance Test
This file contains 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
<html> | |
<head> | |
</head> | |
<body> | |
<script> | |
var i, | |
max = 10000000; | |
for(i = 0; i < max; ++i); | |
var t1 = (new Date).getTime(); | |
var arr = []; | |
for(i = 0; i < max; ++i) | |
arr.push(i); | |
var t2 = (new Date).getTime(); | |
var arr = []; | |
for(i = 0; i < max; ++i) | |
arr[arr.length] = i; | |
var t3 = (new Date).getTime(); | |
document.write('first: ' + (t2 - t1) + ' second: ' + (t3 - t2)); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://blog.xuite.net/vexed/tech/22696106