Last active
January 8, 2016 10:25
-
-
Save barca/d853d52297de7cf788b4 to your computer and use it in GitHub Desktop.
test the performance of let and var
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
// basic performance test of let and var in node v5.2.0 | |
"use strict" | |
var n = Date.now(); | |
var count = 0; | |
for(var i = 0; i < 10000000000; i++){ | |
count += i; | |
} | |
console.log(Date.now() - n); | |
//run 1:35443 | |
//run 2:35779 | |
//run 3:35415 | |
var now = Date.now(); | |
var ct = 0; | |
for(let i = 0; i < 10000000000; i++){ | |
count += i; | |
} | |
console.log(Date.now() - now); | |
//run 1:20660 | |
//run 2:20654 | |
//run 3:20735 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment