Created
November 29, 2016 06:40
-
-
Save mraleph/af62501f3b52d581751e88f11edcf3cb 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 = "es5"; | |
| 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 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