es-toolkit/benchmarks/performance/size.bench.ts
오병진 fcc166a8fa
feat(size, compat): implement size function (#275)
* feat(size, compat): implement size function

Signed-off-by: sunrabbit123 <qudwls185@naver.com>

* fix: typo

Signed-off-by: sunrabbit123 <qudwls185@naver.com>

* bench(size): add benchamrk code

Signed-off-by: sunrabbit123 <qudwls185@naver.com>

* enhance(size): refactor size implementation

Signed-off-by: sunrabbit123 <qudwls185@naver.com>

* remove: unused code

Signed-off-by: sunrabbit123 <qudwls185@naver.com>

* fix: type check

Signed-off-by: sunrabbit123 <qudwls185@naver.com>

* fix: typo

Signed-off-by: sunrabbit123 <qudwls185@naver.com>

---------

Signed-off-by: sunrabbit123 <qudwls185@naver.com>
2024-07-31 22:00:02 +09:00

40 lines
836 B
TypeScript

import { bench, describe } from 'vitest';
import { size as sizeToolkit } from 'es-toolkit';
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],
])
);
});
});