es-toolkit/benchmarks/performance/after.bench.ts
정해준 231b7ef83c
feat(after): Add after (#258)
* feat(after): Add after function

* feat(after): Add after test code

* feat(after): Add after benchmark

* feat(after): Add after docs

* fix(after): should create a function that unc only after being called
 calls

* docs(after): change the after function docs

* Apply suggestions from code review

* Apply suggestions from code review

---------

Co-authored-by: Sojin Park <raon0211@gmail.com>
Co-authored-by: Sojin Park <raon0211@toss.im>
2024-07-21 21:24:00 +09:00

24 lines
600 B
TypeScript

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