Created
May 3, 2017 03:45
-
-
Save sebdeckers/f110f4c5f65fc70da39587cb5d0fba68 to your computer and use it in GitHub Desktop.
Revisions
-
sebdeckers created this gist
May 3, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ var Benchmark = require('benchmark'); var suite = new Benchmark.Suite; var arr = [1,2,3,4,5,6,7,8,9,0] suite.add('for', function() { for (var i = 0, len = arr.length; i < len; i++) { var item = arr[i]; item + 1; } }) .add('for-of', function() { for (var item of arr) { item + 1; } }) .on('cycle', function(event) { console.log(String(event.target)); }) .on('complete', function() { console.log('Fastest is ' + this.filter('fastest').map('name')); }) .run({ 'async': true });