Skip to content

Instantly share code, notes, and snippets.

@mraleph
Created November 29, 2016 07:39
Show Gist options
  • Save mraleph/02db93d6f238be680495290b5e3d3438 to your computer and use it in GitHub Desktop.
Save mraleph/02db93d6f238be680495290b5e3d3438 to your computer and use it in GitHub Desktop.
//var mode = arguments[0]
var mode = "foo";
function es6(a, b, c) {
return Math.max(...[a, b, c]);
}
function es5(a, b, c) {
return Math.max.apply(null, [a, b, c]);
}
function foo(a, b, c) {
return a instanceof es5;
}
function benchmark(f) {
var start = Date.now();
for (var i = 0; i < 1000000; i++) {
f(1, 2, 3);
}
var end = Date.now();
return (end - start);
}
var f = (function () {return this})()[mode];
print('benchmarking...');
print(f);
benchmark(f);
benchmark(f);
benchmark(f);
print(benchmark(f) + ' ms per 1000000 iterations');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment