Skip to content

Instantly share code, notes, and snippets.

@barca
Last active January 8, 2016 10:25
Show Gist options
  • Save barca/d853d52297de7cf788b4 to your computer and use it in GitHub Desktop.
Save barca/d853d52297de7cf788b4 to your computer and use it in GitHub Desktop.
test the performance of let and var
// 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