es-toolkit/benchmarks/keyBy.bench.ts
Dongho Kim 184ce1778d
feat(keyBy): Add keyBy (#93)
* feat(keyBy): Add keyBy

* docs(keyBy): Translate title into Korean

* Update docs/ko/reference/array/keyBy.md

---------

Co-authored-by: Sojin Park <raon0211@gmail.com>
2024-06-30 12:17:00 +09:00

30 lines
740 B
TypeScript

import { bench, describe } from 'vitest';
import { keyBy as keyByToolkit } from 'es-toolkit';
import { keyBy as keyByLodash } from 'lodash';
describe('keyBy', () => {
bench('es-toolkit/keyBy', () => {
const people = [
{ name: 'mike', age: 20 },
{ name: 'jake', age: 30 },
{ name: 'john', age: 25 },
{ name: 'sarah', age: 25 },
{ name: 'emma', age: 25 },
];
keyByToolkit(people, person => person.name);
});
bench('lodash/keyBy', () => {
const people = [
{ name: 'mike', age: 20 },
{ name: 'jake', age: 30 },
{ name: 'john', age: 25 },
{ name: 'sarah', age: 25 },
{ name: 'emma', age: 25 },
];
keyByLodash(people, person => person.name);
});
});