es-toolkit/benchmarks/performance/upperFirst.bench.ts
mattiacoll 16fda3f24c
feat(upperFirst): Add upperFirst function (#404)
* feat(upperFirst): Add upperFirst function

* Add upperFirst benchmark

* Add upperFirst english docs

* Update docs/reference/string/upperFirst.md

---------

Co-authored-by: Sojin Park <raon0211@gmail.com>
Co-authored-by: Sojin Park <raon0211@toss.im>
2024-08-25 22:15:19 +09:00

29 lines
724 B
TypeScript

import { bench, describe } from 'vitest';
import { upperFirst as upperFirstToolkit } from 'es-toolkit';
import { upperFirst as upperFirstLodash } from 'lodash';
describe('upperFirst', () => {
describe('short string', () => {
bench('es-toolkit/upperFirst', () => {
const str = 'camelCase';
upperFirstToolkit(str);
});
bench('lodash/upperFirst', () => {
const str = 'camelCase';
upperFirstLodash(str);
});
});
describe('long string', () => {
const LONG_STR = 'camelCaseLongString'.repeat(1000);
bench('es-toolkit/upperFirst', () => {
upperFirstToolkit(LONG_STR);
});
bench('lodash/upperFirst', () => {
upperFirstLodash(LONG_STR);
});
});
});