jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
function camel(str) {
var arr = str.split('-');
var arr1 = [];
var arr2;
arr.forEach(function(currStr, index) {
var arr2 = currStr.split('');
if (index === 0) {
arr2[0] = arr2[0].toLowerCase();
} else {
arr2[0] = arr2[0].toUpperCase();
}
arr1.push(arr2.join(''));
});
return arr1.join('');
}
function dashToCamel(str) {
var arr = str.split('-');
var output = arr[0];
for (var i = 1; i < arr.length; i++) {
output += arr[i].charAt(0).toUpperCase() + arr[i].slice(1, arr[i].length);
}
return output;
}
var reg = /\-./g;
var replacer = function(a) {
return a.substr(1).toUpperCase();
};
var dashToCamel2 = function(str) {
return str.replace(reg, replacer);
};
function camelize(input) {
var arr = input.split('-');
var camelArr = [arr[0]];
for (var i = 1; i < arr.length; i++) {
camelArr.push((arr[i].charAt(0).toUpperCase() + arr[i].substring(1)));
}
return camelArr.join('');
}
function capitalize(str) {
var ret = str;
if (str.length) {
ret = str.slice(0, 1).toUpperCase() + str.slice(1);
}
return ret;
}
function kabober(str, delim) {
delim = delim || '-';
var arr = str.split(delim);
var ret = arr.shift();
var chunk = arr.shift();
while (arr.length) {
chunk = capitalize(chunk);
ret += chunk;
chunk = arr.shift();
}
return ret;
}
function toCamel(str) {
return str.split('-').reduce(function(memo, token) {
return memo + token.slice(0, 1).toUpperCase() + token.slice(1);
});
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Ron |
| ready |
Tim |
| ready |
Matt |
| ready |
James |
| ready |
Dale |
| ready |
Rob |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.