es-toolkit/benchmarks/unionWith.bench.ts
Jun 3cc1a03519
chore(*): Add codspeed for benchmark visualization (#75)
* chore: add codspeed

* chore: fix the benchmark file to clearly distinguish between the comparison targets

* chore: fix typo
2024-06-18 10:40:07 +09:00

20 lines
660 B
TypeScript

import { bench, describe } from 'vitest';
import { unionWith as unionWithToolkit } from 'es-toolkit';
import { unionWith as unionWithLodash } from 'lodash';
describe('unionWith', () => {
bench('es-toolkit/unionWith', () => {
const array1 = [{ id: 1 }, { id: 2 }];
const array2 = [{ id: 2 }, { id: 3 }];
const areItemsEqual = (a, b) => a.id === b.id;
unionWithToolkit(array1, array2, areItemsEqual);
});
bench('lodash/unionWith', () => {
const array1 = [{ id: 1 }, { id: 2 }];
const array2 = [{ id: 2 }, { id: 3 }];
const areItemsEqual = (a, b) => a.id === b.id;
unionWithLodash(array1, array2, areItemsEqual);
});
});