es-toolkit/benchmarks/performance/before.bench.ts
정해준 0c6f7c95f1
feat(before): Add before (#315)
* feat(before): Add before function

* feat(before): Add before test code

* feat(before): Add before docs

* feat(before): Add before benchmarks

---------

Co-authored-by: Sojin Park <raon0211@toss.im>
2024-07-25 11:39:18 +09:00

26 lines
609 B
TypeScript

import { bench, describe } from 'vitest';
import { before as beforeToolkit } from 'es-toolkit';
import { before as beforeLodash } from 'lodash';
describe('before', () => {
bench('es-toolkit/before', () => {
const add = (a: number, b: number) => a + b;
const n = 10;
const beforeFn = beforeToolkit(10, add);
for (let i = 0; i < n; i++) {
beforeFn(1, 2);
}
});
bench('lodash/before', () => {
const add = (a: number, b: number) => a + b;
const n = 10;
const beforeFn = beforeLodash(10, add);
for (let i = 0; i < n; i++) {
beforeFn(1, 2);
}
});
});