From 7d52ab7c544c98641aa492dc6e5643a8cbde0d62 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 29 Oct 2013 23:58:40 -0700 Subject: [PATCH] Add `_.partial` perf tests. --- perf/perf.js | 62 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/perf/perf.js b/perf/perf.js index 789f5bc6d..a51a33ffd 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -280,8 +280,7 @@ }\ \ if (typeof bind != "undefined") {\ - var thisArg = { "name": "fred" },\ - ctor = function() {};\ + var thisArg = { "name": "fred" };\ \ var func = function(greeting, punctuation) {\ return greeting + " " + this.name + (punctuation || ".");\ @@ -483,6 +482,15 @@ }\ }\ \ + if (typeof partial != "undefined") {\ + var func = function(greeting, punctuation) {\ + return greeting + " fred" + (punctuation || ".");\ + };\ + \ + var _partial = _.partial(func, "hi"),\ + lodashPartial = lodash.partial(func, "hi");\ + }\ + \ if (typeof template != "undefined") {\ var tplData = {\ "header1": "Header1",\ @@ -615,18 +623,6 @@ }) ); - suites.push( - Benchmark.Suite('bound call') - .add(buildName, { - 'fn': 'lodashBoundNormal()', - 'teardown': 'function bind(){}' - }) - .add(otherName, { - 'fn': '_boundNormal()', - 'teardown': 'function bind(){}' - }) - ); - suites.push( Benchmark.Suite('bound call with arguments') .add(buildName, { @@ -639,18 +635,6 @@ }) ); - suites.push( - Benchmark.Suite('bound and partially applied call') - .add(buildName, { - 'fn': 'lodashBoundPartial()', - 'teardown': 'function bind(){}' - }) - .add(otherName, { - 'fn': '_boundPartial()', - 'teardown': 'function bind(){}' - }) - ); - suites.push( Benchmark.Suite('bound and partially applied call with arguments') .add(buildName, { @@ -1477,6 +1461,32 @@ ); /*--------------------------------------------------------------------------*/ +suites.length = 0; + suites.push( + Benchmark.Suite('`_.partial`') + .add(buildName, { + 'fn': 'lodash.partial(func, "hi")', + 'teardown': 'function partial(){}' + }) + .add(otherName, { + 'fn': '_.partial(func, "hi")', + 'teardown': 'function partial(){}' + }) + ); + + suites.push( + Benchmark.Suite('partially applied call with arguments') + .add(buildName, { + 'fn': 'lodashPartial("!")', + 'teardown': 'function partial(){}' + }) + .add(otherName, { + 'fn': '_partial("!")', + 'teardown': 'function partial(){}' + }) + ); + + /*--------------------------------------------------------------------------*/ suites.push( Benchmark.Suite('`_.pick`')