Skip to content
Open
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
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/camelCase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ describe('camelCase bundle size', () => {

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'camelCase');
expect(bundleSize).toMatchInlineSnapshot(`650`);
expect(bundleSize).toMatchInlineSnapshot(`1287`);
});
});
14 changes: 14 additions & 0 deletions benchmarks/bundle-size/chain.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, expect, it } from 'vitest';
import { getBundleSize } from './utils/getBundleSize';

describe('chain bundle size', () => {
it('es-toolkit', async () => {
const bundleSize = await getBundleSize('es-toolkit/iterator', 'chain');
expect(bundleSize).toMatchInlineSnapshot(`82`);
});

it('itertools', async () => {
const bundleSize = await getBundleSize('itertools', 'chain');
expect(bundleSize).toMatchInlineSnapshot(`252`);
});
});
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/clone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('clone bundle size', () => {

it('es-toolkit', async () => {
const bundleSize = await getBundleSize('es-toolkit', 'clone');
expect(bundleSize).toMatchInlineSnapshot(`866`);
expect(bundleSize).toMatchInlineSnapshot(`1001`);
});

it('es-toolkit/compat', async () => {
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/bundle-size/cloneDeep.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ describe('cloneDeep bundle size', () => {

it('es-toolkit', async () => {
const bundleSize = await getBundleSize('es-toolkit', 'cloneDeep');
expect(bundleSize).toMatchInlineSnapshot(`3171`);
expect(bundleSize).toMatchInlineSnapshot(`3200`);
});

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'cloneDeep');
expect(bundleSize).toMatchInlineSnapshot(`3522`);
expect(bundleSize).toMatchInlineSnapshot(`3640`);
});
});
14 changes: 14 additions & 0 deletions benchmarks/bundle-size/enumerate.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, expect, it } from 'vitest';
import { getBundleSize } from './utils/getBundleSize';

describe('enumerate bundle size', () => {
it('es-toolkit', async () => {
const bundleSize = await getBundleSize('es-toolkit/iterator', 'enumerate');
expect(bundleSize).toMatchInlineSnapshot(`212`);
});

it('@fxts/core', async () => {
const bundleSize = await getBundleSize('@fxts/core', 'zipWithIndex');
expect(bundleSize).toMatchInlineSnapshot(`2710`);
});
});
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/find.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ describe('find bundle size', () => {

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'find');
expect(bundleSize).toMatchInlineSnapshot(`7763`);
expect(bundleSize).toMatchInlineSnapshot(`7887`);
});
});
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/findKey.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ describe('findKey bundle size', () => {

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'findKey');
expect(bundleSize).toMatchInlineSnapshot(`7688`);
expect(bundleSize).toMatchInlineSnapshot(`7812`);
});
});
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/lastIndexOf.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getBundleSize } from './utils/getBundleSize';
describe('lastIndexOf bundle size', () => {
it('lodash-es', async () => {
const bundleSize = await getBundleSize('lodash-es', 'lastIndexOf');
expect(bundleSize).toMatchInlineSnapshot(`1586`);
expect(bundleSize).toMatchInlineSnapshot(`2481`);
});

it('es-toolkit/compat', async () => {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/mapKeys.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ describe('mapKeys bundle size', () => {

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'mapKeys');
expect(bundleSize).toMatchInlineSnapshot(`7701`);
expect(bundleSize).toMatchInlineSnapshot(`7825`);
});
});
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/mapValues.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ describe('mapValues bundle size', () => {

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'mapValues');
expect(bundleSize).toMatchInlineSnapshot(`7701`);
expect(bundleSize).toMatchInlineSnapshot(`7825`);
});
});
4 changes: 2 additions & 2 deletions benchmarks/bundle-size/merge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ describe('merge bundle size', () => {

it('es-toolkit', async () => {
const bundleSize = await getBundleSize('es-toolkit', 'merge');
expect(bundleSize).toMatchInlineSnapshot(`521`);
expect(bundleSize).toMatchInlineSnapshot(`542`);
});

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'merge');
expect(bundleSize).toMatchInlineSnapshot(`5721`);
expect(bundleSize).toMatchInlineSnapshot(`6206`);
});
});
4 changes: 2 additions & 2 deletions benchmarks/bundle-size/mergeWith.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ describe('mergeWith bundle size', () => {

it('es-toolkit', async () => {
const bundleSize = await getBundleSize('es-toolkit', 'mergeWith');
expect(bundleSize).toMatchInlineSnapshot(`368`);
expect(bundleSize).toMatchInlineSnapshot(`564`);
});

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'mergeWith');
expect(bundleSize).toMatchInlineSnapshot(`5665`);
expect(bundleSize).toMatchInlineSnapshot(`6150`);
});
});
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/omit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ describe('omit bundle size', () => {

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'omit');
expect(bundleSize).toMatchInlineSnapshot(`8042`);
expect(bundleSize).toMatchInlineSnapshot(`8227`);
});
});
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/throttle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('throttle bundle size', () => {

it('es-toolkit', async () => {
const bundleSize = await getBundleSize('es-toolkit', 'throttle');
expect(bundleSize).toMatchInlineSnapshot(`764`);
expect(bundleSize).toMatchInlineSnapshot(`855`);
});

it('es-toolkit/compat', async () => {
Expand Down
4 changes: 3 additions & 1 deletion benchmarks/bundle-size/utils/getBundleSize.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import esbuild from 'esbuild';
import path from 'path';

export async function getBundleSize(pkg: 'lodash-es' | 'es-toolkit' | 'es-toolkit/compat', funcName: string) {
type Package = 'lodash-es' | 'es-toolkit' | 'es-toolkit/compat' | 'es-toolkit/iterator' | 'itertools' | '@fxts/core';

export async function getBundleSize(pkg: Package, funcName: string) {
const script = `import { ${funcName} } from "${pkg}"; console.log(${funcName})`;

const bundled = await esbuild.build({
Expand Down
19 changes: 19 additions & 0 deletions benchmarks/bundle-size/zipIterable.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest';
import { getBundleSize } from './utils/getBundleSize';

describe('zipIterable bundle size', () => {
it('es-toolkit', async () => {
const bundleSize = await getBundleSize('es-toolkit/iterator', 'zipIterable');
expect(bundleSize).toMatchInlineSnapshot(`197`);
});

it('@fxts/core', async () => {
const bundleSize = await getBundleSize('@fxts/core', 'zip');
expect(bundleSize).toMatchInlineSnapshot(`6336`);
});

it('itertools', async () => {
const bundleSize = await getBundleSize('itertools', 'izip');
expect(bundleSize).toMatchInlineSnapshot(`337`);
});
});
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/zipObjectDeep.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ describe('zipObjectDeep bundle size', () => {

it('es-toolkit/compat', async () => {
const bundleSize = await getBundleSize('es-toolkit/compat', 'zipObjectDeep');
expect(bundleSize).toMatchInlineSnapshot(`2297`);
expect(bundleSize).toMatchInlineSnapshot(`2935`);
});
});
2 changes: 1 addition & 1 deletion benchmarks/bundle-size/zipWith.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('zipWith bundle size', () => {

it('es-toolkit', async () => {
const bundleSize = await getBundleSize('es-toolkit', 'zipWith');
expect(bundleSize).toMatchInlineSnapshot(`198`);
expect(bundleSize).toMatchInlineSnapshot(`200`);
});

it('es-toolkit/compat', async () => {
Expand Down
2 changes: 2 additions & 0 deletions benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"vitest": "^4.0.17"
},
"devDependencies": {
"@fxts/core": "^1.26.0",
"@types/lodash": "^4.17.20",
"@types/lodash-es": "^4",
"itertools": "^2.6.0",
"rfdc": "^1.4.1"
}
}
58 changes: 58 additions & 0 deletions benchmarks/performance/chain.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { bench, describe } from 'vitest';
import { chain as chainEsToolkit_ } from 'es-toolkit/iterator';
import { chain as chainItertools_ } from 'itertools';

const chainEsToolkit = chainEsToolkit_;
const chainItertools = chainItertools_;

describe('chain', () => {
bench('es-toolkit/chain', () => {
const iter = chainEsToolkit([1, 2, 3], [4, 5, 6], [7, 8, 9]);
for (const _ of iter) {
/* consume */
}
});

bench('itertools/ichain', () => {
const iter = chainItertools([1, 2, 3], [4, 5, 6], [7, 8, 9]);
for (const _ of iter) {
/* consume */
}
});

bench('native spread', () => {
const iter = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
].flat();
for (const _ of iter) {
/* consume */
}
});
});

describe('chain/largeArray', () => {
const largeArray = Array.from({ length: 10000 }, (_, i) => i);

bench('es-toolkit/chain', () => {
const iter = chainEsToolkit(largeArray, largeArray, largeArray);
for (const _ of iter) {
/* consume */
}
});

bench('itertools/ichain', () => {
const iter = chainItertools(largeArray, largeArray, largeArray);
for (const _ of iter) {
/* consume */
}
});

bench('native spread', () => {
const iter = [...largeArray, ...largeArray, ...largeArray];
for (const _ of iter) {
/* consume */
}
});
});
66 changes: 66 additions & 0 deletions benchmarks/performance/enumerate.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { bench, describe } from 'vitest';
import { enumerate as enumerateEsToolkit_ } from 'es-toolkit/iterator';
import { zipWithIndex as zipWithIndexFxts_ } from '@fxts/core';

const enumerateEsToolkit = enumerateEsToolkit_;
const zipWithIndexFxts = zipWithIndexFxts_;

describe('enumerate', () => {
bench('es-toolkit/enumerate', () => {
const iter = enumerateEsToolkit(['a', 'b', 'c']);
for (const _ of iter) {
/* consume */
}
});

bench('@fxts/core/zipWithIndex', () => {
const iter = zipWithIndexFxts(['a', 'b', 'c']);
for (const _ of iter) {
/* consume */
}
});

bench('Array.prototype.entries (native)', () => {
const arr = ['a', 'b', 'c'];
for (const _ of arr.entries()) {
/* consume */
}
});

bench('forEach with index (native)', () => {
const arr = ['a', 'b', 'c'];
arr.forEach((_, __) => {
/* consume */
});
});
});

describe('enumerate/largeArray', () => {
const largeArray = Array.from({ length: 10000 }, (_, i) => String(i));

bench('es-toolkit/enumerate', () => {
const iter = enumerateEsToolkit(largeArray);
for (const _ of iter) {
/* consume */
}
});

bench('@fxts/core/zipWithIndex', () => {
const iter = zipWithIndexFxts(largeArray);
for (const _ of iter) {
/* consume */
}
});

bench('Array.prototype.entries (native)', () => {
for (const _ of largeArray.entries()) {
/* consume */
}
});

bench('forEach with index (native)', () => {
largeArray.forEach((_, __) => {
/* consume */
});
});
});
56 changes: 56 additions & 0 deletions benchmarks/performance/zipIterable.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { bench, describe } from 'vitest';
import { zipIterable as zipIterableEsToolkit_ } from 'es-toolkit/iterator';
import { izip as zipItertools_ } from 'itertools';
import { zip as zipFxts_ } from '@fxts/core';

const zipIterableEsToolkit = zipIterableEsToolkit_;
const zipFxts = zipFxts_;
const zipItertools = zipItertools_;

describe('zipIterable', () => {
bench('es-toolkit/zipIterable', () => {
const iter = zipIterableEsToolkit([1, 2, 3], ['a', 'b', 'c']);
for (const _ of iter) {
/* consume */
}
});

bench('@fxts/core/zip', () => {
const iter = zipFxts([1, 2, 3], ['a', 'b', 'c']);
for (const _ of iter) {
/* consume */
}
});

bench('itertools/izip', () => {
const iter = zipItertools([1, 2, 3], ['a', 'b', 'c']);
for (const _ of iter) {
/* consume */
}
});
});

describe('zipIterable/largeArray', () => {
const largeArray = Array.from({ length: 10000 }, (_, i) => i);

bench('es-toolkit/zipIterable', () => {
const iter = zipIterableEsToolkit(largeArray, largeArray);
for (const _ of iter) {
/* consume */
}
});

bench('@fxts/core/zip', () => {
const iter = zipFxts(largeArray, largeArray);
for (const _ of iter) {
/* consume */
}
});

bench('itertools/izip', () => {
const iter = zipItertools(largeArray, largeArray);
for (const _ of iter) {
/* consume */
}
});
});
Loading