Last active
August 29, 2015 14:26
-
-
Save lpinca/b75c5fa4321a89e9eed2 to your computer and use it in GitHub Desktop.
Test case for redis/ioredis#120
This file contains 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
'use strict'; | |
var Benchmark = require('benchmark') | |
, _ = require('lodash'); | |
var suite = new Benchmark.Suite() | |
, arr = [] | |
, i; | |
for (i = 0; i < 1000; i++) arr.push(i); | |
suite.add('without copy loop', function () { | |
var args = new Array(1); | |
args[0] = arr; | |
_.flatten(args); | |
}) | |
.add('with copy loop', function () { | |
var args = new Array(arr.length) | |
, i; | |
for (i = 0; i < arr.length; i++) args[i] = arr[i]; | |
_.flatten(args); | |
}) | |
.on('cycle', function (event) { | |
console.log(String(event.target)); | |
}) | |
.on('complete', function() { | |
console.log('Fastest is ' + this.filter('fastest').pluck('name')); | |
}) | |
.run({ 'async': true }); |
This file contains 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
{ | |
"name": "ioredis-120", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"dependencies": { | |
"benchmark": "^1.0.0", | |
"lodash": "^3.10.0" | |
}, | |
"devDependencies": {}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment