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 getInput(data){
var lines = data.split(/\n/);
return lines;
}
function stringToByteArray(str){
var arr = [],
utf8;
utf8 = unescape(encodeURIComponent(str));
for (var i = 0; i < utf8.length; i++){
arr.push(utf8.charCodeAt(i));
}
return arr;
}
function fletcHelp(str){
var result = stringToByteArray(str);
return fletcher16(result);
}
function fletcher16(arr){
var sum1 = 0,
sum2 = 0;
for (var i = 0; i < arr.length; i++){
sum1 = (sum1 + arr[i]) % 255;
sum2 = (sum2 + sum1) % 255;
}
return ((sum2 << 8) | sum1).toString(16);
}
function compute(input){
var data = getInput(input),
result = [],
newline = "\n";
for (var i = 1; i < data.length; i++){
result.push(i + " ");
result.push(fletcHelp(data[i]));
result.push(newline);
}
result.pop();
return result.join("");
}
var test = "8\nWhen you're parsing a file, which I was\n(and which programs do very often, probably more so than interactively\n prompting the user)it makes sense to include\n as part of the data. Also, \nif you plan on getting serious with C, you should look into malloc() and free(). They are essential if you are \nmaking programs with more than just the primitives. Run '$ man 3 malloc' on the command line to see the\n documentation for free(), malloc() and friends (that is, if you're on a UNIX system). \nThe man pages are an indispensable resource for C programming."
Ready to run.
Test | Ops/sec | |
---|---|---|
MyTest |
| ready |
test2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.