Update curry benchmark

This commit is contained in:
Aaron Jensen 2015-08-12 21:19:09 -07:00
parent 9b1b6bb44a
commit e99d575972

View File

@ -3,12 +3,15 @@ const Benchmark = require('benchmark');
const u = require('../lib'); const u = require('../lib');
const _ = require('lodash'); const _ = require('lodash');
const { curry4 } = require('../lib/util/curry'); const { curry2, curry4 } = require('../lib/util/curry');
const add = (a, b, c, d) => a + b + c + d; const add4 = (a, b, c, d) => a + b + c + d;
const add2 = (a, b) => a + b;
const fakeCurryAdd = x => y => x + y; const fakeCurryAdd = x => y => x + y;
const curryAdd = _.curry(add); const lodashCurryAdd2 = _.curry(add2);
const updeepCurry = curry4(add); const updeepCurryAdd2 = curry2(add2);
const lodashCurryAdd4 = _.curry(add4);
const updeepCurryAdd4 = curry4(add4);
// const updeepCurryBig = curry.curryBig(add); // const updeepCurryBig = curry.curryBig(add);
const array = [0, 1, 2, 3, 4, 5]; const array = [0, 1, 2, 3, 4, 5];
@ -44,8 +47,20 @@ function createSuite(suiteName, tests) {
const curryVsLodash = createSuite('Curry', { const curryVsLodash = createSuite('Curry', {
'updeep curry partial call': () => updeepCurry(3)(4)(5)(6), 'updeep curry': () => {
'lodash curry partial call': () => curryAdd(3)(4)(5)(6), updeepCurryAdd4(3)(4)(5)(6);
updeepCurryAdd4(3, 4, 5, 6);
updeepCurryAdd4(u._, 4, u._, 6)(3, 4);
updeepCurryAdd2(3)(4);
updeepCurryAdd2(3, 4);
},
'lodash curry': () => {
lodashCurryAdd4(3)(4)(5)(6);
lodashCurryAdd4(3, 4, 5, 6);
lodashCurryAdd4(_, 4, _, 6)(3, 4);
lodashCurryAdd2(3)(4);
lodashCurryAdd2(3, 4);
},
}); });
const mapVsLodash = createSuite('Map', { const mapVsLodash = createSuite('Map', {