Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: import benchmark functions directly to fix odd performance issues #22

Merged
merged 4 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
"prettier/@typescript-eslint"
],
"parserOptions": {
"project": "./tsconfig.json"
"project": "./tsconfig.eslint.json"
},
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"no-control-regex": "off",
"prefer-const": [
Expand Down
6 changes: 4 additions & 2 deletions benchmark/assign.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const utils = require('../dist')
const {
assign
} = require('../dist')
const lodash = require('lodash/assign')

function Foo() {
Expand All @@ -12,7 +14,7 @@ function Bar() {
Foo.prototype.b = 2;
Bar.prototype.d = 4;

exports['utils'] = () => utils.assign({
exports['utils'] = () => assign({
'a': 0
}, new Foo, new Bar);

Expand Down
6 changes: 4 additions & 2 deletions benchmark/at.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const utils = require('../dist')
const {
at
} = require('../dist')
const lodash = require('lodash/at')

var object = {
Expand All @@ -14,6 +16,6 @@ var object = {
},
};

exports['utils'] = () => utils.at(object, ['a.b.c', 'x.y.z']);
exports['utils'] = () => at(object, ['a.b.c', 'x.y.z']);

exports['lodash'] = () => lodash(object, ['a.b.c', 'x.y.z']);
6 changes: 4 additions & 2 deletions benchmark/camel-case.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
camelCase
} = require('../dist')
const lodash = require('lodash/camelCase')

exports['utils'] = () => utils.camelCase('Foo Bar');
exports['utils'] = () => camelCase('Foo Bar');

exports['lodash'] = () => lodash('Foo Bar');
6 changes: 4 additions & 2 deletions benchmark/cast-array.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
castArray
} = require('../dist')
const lodash = require('lodash/castArray')

exports['utils'] = () => utils.castArray('abc');
exports['utils'] = () => castArray('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/chunk.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
chunk
} = require('../dist')
const lodash = require('lodash/chunk')

exports['utils'] = () => utils.chunk(['a', 'b', 'c', 'd'], 2);
exports['utils'] = () => chunk(['a', 'b', 'c', 'd'], 2);

exports['lodash'] = () => lodash(['a', 'b', 'c', 'd'], 2);
6 changes: 4 additions & 2 deletions benchmark/clone-deep.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const utils = require('../dist')
const {
cloneDeep
} = require('../dist')
const lodash = require('lodash/cloneDeep')

const objects = [{
Expand All @@ -7,6 +9,6 @@ const objects = [{
b: 2
}];

exports['utils'] = () => utils.cloneDeep(objects);
exports['utils'] = () => cloneDeep(objects);

exports['lodash'] = () => lodash(objects);
6 changes: 4 additions & 2 deletions benchmark/clone.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const utils = require('../dist')
const {
clone
} = require('../dist')
const lodash = require('lodash/clone')

const objects = [{
Expand All @@ -7,6 +9,6 @@ const objects = [{
b: 2
}];

exports['utils'] = () => utils.clone(objects);
exports['utils'] = () => clone(objects);

exports['lodash'] = () => lodash(objects);
6 changes: 4 additions & 2 deletions benchmark/concat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
concat
} = require('../dist')
const lodash = require('lodash/concat')

exports['utils'] = () => utils.concat([1], [2]);
exports['utils'] = () => concat([1], [2]);

exports['lodash'] = () => lodash([1], [2]);
6 changes: 4 additions & 2 deletions benchmark/fill.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
fill
} = require('../dist')
const lodash = require('lodash/fill')

exports['utils'] = () => utils.fill([1, 2, 3], 'a');
exports['utils'] = () => fill([1, 2, 3], 'a');

exports['lodash'] = () => lodash([1, 2, 3], 'a');
8 changes: 6 additions & 2 deletions benchmark/filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const utils = require('../dist')
const {
filter
} = require('../dist')
const lodash = require('lodash/filter')

const users = [{
Expand All @@ -13,6 +15,8 @@ const users = [{
}
];

exports['utils'] = () => utils.filter(users, o => !o.active);
exports['native'] = () => users.filter(o => !o.active);

exports['utils'] = () => filter(users, o => !o.active);

exports['lodash'] = () => lodash(users, o => !o.active);
6 changes: 4 additions & 2 deletions benchmark/find-key.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const utils = require('../dist')
const {
findKey
} = require('../dist')
const lodash = require('lodash/findKey')

const users = {
Expand All @@ -16,6 +18,6 @@ const users = {
}
};

exports['utils'] = () => utils.findKey(users, o => o.age < 40);
exports['utils'] = () => findKey(users, o => o.age < 40);

exports['lodash'] = () => lodash(users, o => o.age < 40);
6 changes: 4 additions & 2 deletions benchmark/flatten.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
flatten
} = require('../dist')
const lodash = require('lodash/flatten')

exports['utils'] = () => utils.flatten([1, [2, [3, [4]], 5]]);
exports['utils'] = () => flatten([1, [2, [3, [4]], 5]]);

exports['lodash'] = () => lodash([1, [2, [3, [4]], 5]]);
6 changes: 4 additions & 2 deletions benchmark/get.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const utils = require('../dist')
const {
get
} = require('../dist')
const lodash = require('lodash/get')

var object = {
Expand All @@ -9,6 +11,6 @@ var object = {
}
};

exports['utils'] = () => utils.get(object, 'a.b.c');
exports['utils'] = () => get(object, 'a.b.c');

exports['lodash'] = () => lodash(object, 'a.b.c');
6 changes: 4 additions & 2 deletions benchmark/group-by.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
groupBy
} = require('../dist')
const lodash = require('lodash/groupBy')

exports['utils'] = () => utils.groupBy([6.1, 4.2, 6.3], Math.floor);
exports['utils'] = () => groupBy([6.1, 4.2, 6.3], Math.floor);

exports['lodash'] = () => lodash([6.1, 4.2, 6.3], Math.floor);
6 changes: 4 additions & 2 deletions benchmark/has.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const utils = require('../dist')
const {
has
} = require('../dist')
const lodash = require('lodash/has')

var object = {
Expand All @@ -7,6 +9,6 @@ var object = {
}
};

exports['utils'] = () => utils.has(object, 'a.b');
exports['utils'] = () => has(object, 'a.b');

exports['lodash'] = () => lodash(object, 'a.b');
6 changes: 4 additions & 2 deletions benchmark/head.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
head
} = require('../dist')
const lodash = require('lodash/head')

exports['utils'] = () => utils.head([1, 2, 3]);
exports['utils'] = () => head([1, 2, 3]);

exports['lodash'] = () => lodash([1, 2, 3]);
6 changes: 4 additions & 2 deletions benchmark/index-of.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
indexOf
} = require('../dist')
const lodash = require('lodash/indexOf')

exports['utils'] = () => utils.indexOf([1, 2, 1, 2], 2);
exports['utils'] = () => indexOf([1, 2, 1, 2], 2);

exports['lodash'] = () => lodash([1, 2, 1, 2], 2);
4 changes: 0 additions & 4 deletions benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@ benchmarker("utils", [
{ name: "Utils.head vs lodash.head", scenarios: require("./head"), },
{ name: "Utils.indexOf vs lodash.indexOf", scenarios: require("./index-of"), },
{ name: "Utils.isArray vs lodash.isArray", scenarios: require("./is-array"), },
{ name: "Utils.isArray vs lodash.isArray", scenarios: require("./is-array"), },
{ name: "Utils.isBoolean vs lodash.isBoolean", scenarios: require("./is-boolean"), },
{ name: "Utils.isBoolean vs lodash.isBoolean", scenarios: require("./is-boolean"), },
{ name: "Utils.isEmpty vs lodash.isEmpty", scenarios: require("./is-empty"), },
{ name: "Utils.isEqual vs lodash.isEqual", scenarios: require("./is-equal"), },
{ name: "Utils.isFunction vs lodash.isFunction", scenarios: require("./is-function"), },
{ name: "Utils.isNil vs lodash.isNil", scenarios: require("./is-nil"), },
{ name: "Utils.isNumber vs lodash.isNumber", scenarios: require("./is-number"), },
{ name: "Utils.isNumber vs lodash.isNumber", scenarios: require("./is-number"), },
{ name: "Utils.isObject vs lodash.isObject", scenarios: require("./is-object"), },
{ name: "Utils.isString vs lodash.isString", scenarios: require("./is-string"), },
{ name: "Utils.isString vs lodash.isString", scenarios: require("./is-string"), },
{ name: "Utils.isSymbol vs lodash.isSymbol", scenarios: require("./is-symbol"), },
{ name: "Utils.isUndefined vs lodash.isUndefined", scenarios: require("./is-undefined"), },
{ name: "Utils.keyBy vs lodash.keyBy", scenarios: require("./key-by"), },
Expand Down
6 changes: 4 additions & 2 deletions benchmark/is-array.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isArray
} = require('../dist')
const lodash = require('lodash/isArray')

exports['utils'] = () => utils.isArray('abc');
exports['utils'] = () => isArray('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-boolean.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isBoolean
} = require('../dist')
const lodash = require('lodash/isBoolean')

exports['utils'] = () => utils.isBoolean('abc');
exports['utils'] = () => isBoolean('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-empty.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isEmpty
} = require('../dist')
const lodash = require('lodash/isEmpty')

exports['utils'] = () => utils.isEmpty('abc');
exports['utils'] = () => isEmpty('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-equal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isEqual
} = require('../dist')
const lodash = require('lodash/isEqual')

exports['utils'] = () => utils.isEqual('abc');
exports['utils'] = () => isEqual('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-function.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isFunction
} = require('../dist')
const lodash = require('lodash/isFunction')

exports['utils'] = () => utils.isFunction('abc');
exports['utils'] = () => isFunction('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-nil.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isNil
} = require('../dist')
const lodash = require('lodash/isNil')

exports['utils'] = () => utils.isNil('abc');
exports['utils'] = () => isNil('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-number.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isNumber
} = require('../dist')
const lodash = require('lodash/isNumber')

exports['utils'] = () => utils.isNumber('abc');
exports['utils'] = () => isNumber('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-object.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isObject
} = require('../dist')
const lodash = require('lodash/isObject')

exports['utils'] = () => utils.isObject('abc');
exports['utils'] = () => isObject('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-string.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isString
} = require('../dist')
const lodash = require('lodash/isString')

exports['utils'] = () => utils.isString('abc');
exports['utils'] = () => isString('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-symbol.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isSymbol
} = require('../dist')
const lodash = require('lodash/isSymbol')

exports['utils'] = () => utils.isSymbol('abc');
exports['utils'] = () => isSymbol('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/is-undefined.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const utils = require('../dist')
const {
isUndefined
} = require('../dist')
const lodash = require('lodash/isUndefined')

exports['utils'] = () => utils.isUndefined('abc');
exports['utils'] = () => isUndefined('abc');

exports['lodash'] = () => lodash('abc');
6 changes: 4 additions & 2 deletions benchmark/key-by.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const utils = require('../dist')
const {
keyBy
} = require('../dist')
const lodash = require('lodash/keyBy')

const array = [{
Expand All @@ -11,6 +13,6 @@ const array = [{
}
];

exports['utils'] = () => utils.keyBy(array, 'dir');
exports['utils'] = () => keyBy(array, 'dir');

exports['lodash'] = () => lodash(array, 'dir');
Loading