es-toolkit/benchmarks/performance/snakeCase.bench.ts
Dayong Lee 31769810b8
feat(string): add snakeCase, startCase, lowerCase, kebabCase in compat layer (#517)
* Add cases function

* Add benchmarks and re-export in index.ts

* Revert
2024-09-13 16:43:07 +09:00

31 lines
1.1 KiB
TypeScript

import { bench, describe } from 'vitest';
import { snakeCase as snakeCaseToolkit } from 'es-toolkit';
import { snakeCase as snakeCaseToolkitCompat } from 'es-toolkit/compat';
import { snakeCase as snakeCaseLodash } from 'lodash';
describe('snakeCase', () => {
bench('es-toolkit/snakeCase', () => {
snakeCaseToolkit('hello world');
snakeCaseToolkit('--foo--bar__baz 123');
snakeCaseToolkit('123numericValues');
snakeCaseToolkit('XMLHttpRequest');
snakeCaseToolkit('hello-World_of XML_httpRequest');
});
bench('es-toolkit/comapt/snakeCase', () => {
snakeCaseToolkitCompat('hello world');
snakeCaseToolkitCompat('--foo--bar__baz 123');
snakeCaseToolkitCompat('123numericValues');
snakeCaseToolkitCompat('XMLHttpRequest');
snakeCaseToolkitCompat('hello-World_of XML_httpRequest');
});
bench('lodash/snakeCase', () => {
snakeCaseLodash('hello world');
snakeCaseLodash('--foo--bar__baz 123');
snakeCaseLodash('123numericValues');
snakeCaseLodash('XMLHttpRequest');
snakeCaseLodash('hello-World_of XML_httpRequest');
});
});