Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
camelize
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Android 13; Mobile; rv:129.0) Gecko/129.0 Firefox/129.0
Browser:
Firefox Mobile 129
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
camelize
484403.2 Ops/sec
toCamelCase
338634.9 Ops/sec
Script Preparation code:
function camelize(str, $ucfirst) { if ($ucfirst === void 0) { $ucfirst = false; } var $return = str.replace(/^([A-Z])|[\s-_]+(\w)/g, function (match, p1, p2) { return p2 ? p2.toUpperCase() : p1.toLowerCase(); }); return $ucfirst ? $return.charAt(0).toUpperCase() + $return.slice(1) : $return; }; function toCamelCase(str) { let s = str && str .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase()) .join(''); return s.slice(0, 1).toLowerCase() + s.slice(1); };
Tests:
camelize
camelize('some_database_field_name'); camelize('Some label that needs to be camelized'); camelize('some-javascript-property'); camelize('some-mixed_string with spaces_underscores-and-hyphens');
toCamelCase
toCamelCase('some_database_field_name'); toCamelCase('Some label that needs to be camelized'); toCamelCase('some-javascript-property'); toCamelCase('some-mixed_string with spaces_underscores-and-hyphens');