From e99d575972b77f6df1491b52e9de041763203fea Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Wed, 12 Aug 2015 21:19:09 -0700 Subject: [PATCH] Update curry benchmark --- perf/index.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/perf/index.js b/perf/index.js index 409ae88..553d872 100644 --- a/perf/index.js +++ b/perf/index.js @@ -3,12 +3,15 @@ const Benchmark = require('benchmark'); const u = require('../lib'); 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 curryAdd = _.curry(add); -const updeepCurry = curry4(add); +const lodashCurryAdd2 = _.curry(add2); +const updeepCurryAdd2 = curry2(add2); +const lodashCurryAdd4 = _.curry(add4); +const updeepCurryAdd4 = curry4(add4); // const updeepCurryBig = curry.curryBig(add); const array = [0, 1, 2, 3, 4, 5]; @@ -44,8 +47,20 @@ function createSuite(suiteName, tests) { const curryVsLodash = createSuite('Curry', { - 'updeep curry partial call': () => updeepCurry(3)(4)(5)(6), - 'lodash curry partial call': () => curryAdd(3)(4)(5)(6), + 'updeep curry': () => { + 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', {