mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-03 13:53:50 +03:00
3cc1a03519
* chore: add codspeed * chore: fix the benchmark file to clearly distinguish between the comparison targets * chore: fix typo
27 lines
688 B
TypeScript
27 lines
688 B
TypeScript
import { bench, describe } from 'vitest';
|
|
import { uniqBy as uniqByToolkit } from 'es-toolkit';
|
|
import { uniqBy as uniqByLodash } from 'lodash';
|
|
import { randomInt } from 'crypto';
|
|
|
|
describe('uniqBy, small arrays', () => {
|
|
bench('es-toolkit/uniqBy', () => {
|
|
uniqByToolkit([2.1, 1.2, 2.3], Math.floor);
|
|
});
|
|
|
|
bench('lodash/uniqBy', () => {
|
|
uniqByLodash([2.1, 1.2, 2.3], Math.floor);
|
|
});
|
|
});
|
|
|
|
describe('uniqBy, large arrays', () => {
|
|
const array = Array.from({ length: 10000 }).map(() => randomInt(0, 10000));
|
|
|
|
bench('es-toolkit/uniqBy', () => {
|
|
uniqByToolkit(array, Math.floor);
|
|
});
|
|
|
|
bench('lodash/uniqBy', () => {
|
|
uniqByLodash(array, Math.floor);
|
|
});
|
|
});
|