Created
November 29, 2016 07:39
-
-
Save mraleph/02db93d6f238be680495290b5e3d3438 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//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