es-toolkit/benchmarks/performance/meanBy.bench.ts
2024-07-17 11:47:39 +09:00

16 lines
431 B
TypeScript

import { bench, describe } from 'vitest';
import { meanBy as meanByToolkit } from 'es-toolkit';
import { meanBy as meanByLodash } from 'lodash';
describe('meanBy', () => {
bench('es-toolkit/meanBy', () => {
const items = [{ a: 1 }, { a: 2 }, { a: 3 }];
meanByToolkit(items, x => x.a);
});
bench('lodash/meanBy', () => {
const items = [{ a: 1 }, { a: 2 }, { a: 3 }];
meanByLodash(items, x => x.a);
});
});