es-toolkit/benchmarks/performance/size.bench.ts

40 lines
843 B
TypeScript
Raw Normal View History

import { bench, describe } from 'vitest';
2024-08-19 15:22:35 +03:00
import { size as sizeToolkit } from 'es-toolkit/compat';
import { size as sizeLodash } from 'lodash';
describe('size', () => {
bench('es-toolkit/size', () => {
sizeToolkit([1, 2, 3, 4]);
sizeToolkit('hello');
sizeToolkit({ a: 1, b: 2, c: 3 });
sizeToolkit([]);
sizeToolkit('');
sizeToolkit({});
sizeToolkit(new Set([1, 2, 3]));
sizeToolkit(
new Map([
['a', 1],
['b', 2],
['c', 3],
])
);
});
bench('lodash/size', () => {
sizeLodash([1, 2, 3, 4]);
sizeLodash('hello');
sizeLodash({ a: 1, b: 2, c: 3 });
sizeLodash([]);
sizeLodash('');
sizeLodash({});
sizeLodash(new Set([1, 2, 3]));
sizeLodash(
new Map([
['a', 1],
['b', 2],
['c', 3],
])
);
});
});