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

19 lines
458 B
TypeScript

import { bench, describe } from 'vitest';
import { invert as invertByLodash } from 'lodash';
import { invert as invertByToolkit } from 'es-toolkit';
const object: { [key: string]: string } = {};
for (let i = 0; i < 10000; i++) {
object[`key${i}`] = `value${i}`;
}
describe('invert function benchmark', () => {
bench('es-toolkit/invert', () => {
invertByToolkit(object);
});
bench('lodash/invert', () => {
invertByLodash(object);
});
});