Skip to content

Instantly share code, notes, and snippets.

@Troush
Created May 11, 2013 09:20
Show Gist options
  • Save Troush/5559412 to your computer and use it in GitHub Desktop.
Save Troush/5559412 to your computer and use it in GitHub Desktop.
function bench (fn) {
var t1 = Date.now();
for (var i = 0; i < 10000000; i++) {
fn();
}
var t2 = Date.now();
console.log(t2 - t1);
}
var fn1 = function() {
var i = '1' + '2' + '3';
}
var fn2 = function() {
var i = '1';
i += '2';
i += '3';
}
bench(fn1);
bench(fn2);
/*
* BVadim from habr
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment