Created
November 12, 2009 14:41
-
-
Save paulsmith/232944 to your computer and use it in GitHub Desktop.
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
FF 3.5 | |
| Run | String(fn) | fn + "" | | |
|-----+-------------+-----------| | |
| 1 | 0.658 | 0.617 | (time in sec.) | |
| 2 | 0.666 | 0.617 | | |
| 3 | 0.651 | 0.61 | | |
| 4 | 0.651 | 0.611 | | |
| 5 | 0.653 | 0.621 | | |
|-----+-------------+-----------| | |
| Sum | 3.279 | 3.076 | | |
| Avg | 0.6558 | 0.6152 | | |
| | % faster -> | 6.5994798 | | |
Chromium 4.0.236.0 (Ubuntu build 31004) | |
| Run | String(fn) | fn + "" | | |
|-----+------------+-------------| | |
| 1 | 0.019 | 0.028 | | |
| 2 | 0.022 | 0.026 | | |
| 3 | 0.033 | 0.027 | | |
| 4 | 0.022 | 0.029 | | |
| 5 | 0.021 | 0.029 | | |
|-----+------------+-------------| | |
| Sum | 0.117 | 0.139 | | |
| Avg | 0.0234 | 0.0278 | | |
| | 15.827338 | <- % faster | |
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> | |
<body> | |
<script> | |
window.onload = function() { | |
var fn = function(a, b) { return a + b; }; | |
var n = 100000; | |
var start = Date.now(); | |
for (var i = 0; i < n; i++) { | |
String(fn); | |
} | |
document.write("<p><b>String(fn):</b> " + (Date.now() - start) / 1000 + " sec.</p>"); | |
var start = Date.now(); | |
for (var i = 0; i < n; i++) { | |
fn + ""; | |
} | |
document.write("<p><b>fn + \"\":</b> " + (Date.now() - start) / 1000 + " sec.</p>"); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment