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

29 lines
724 B
TypeScript
Raw Normal View History

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