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
<script>
function max(n1, n2) {
n1 = parseInt(n1, 10);
n2 = parseInt(n2, 10);
return n1 > n2 ? n1 : n2;
}
function AddFillerLeft(number, filler, length) {
var str = '' + number;
var fillerArray = new Array(max(length - str.length, 0) + 1);
return fillerArray.join(filler) + str;
}
var ByteArray = {};
ByteArray.ToHexStr_listpush = function(bytearray) {
var result = [];
var length = bytearray.length;
for (var i = 0;i < length;++i) {
result.push(AddFillerLeft(bytearray[i].toString(16).toUpperCase(), '0', 2));
}
return result.join('');
};
ByteArray._HexTable = {};
for (var i = 0;i < 256;++i) {
ByteArray._HexTable[i] = AddFillerLeft(i.toString(16).toUpperCase(), '0', 2);
}
ByteArray.ToHexStr_stringconcat = function(bytearray) {
var result = '';
var length = bytearray.length;
for (var i = 0;i < length;++i) {
result += AddFillerLeft(bytearray[i].toString(16).toUpperCase(), '0', 2);
}
return result;
};
ByteArray.ToHexStr_table = function(bytearray) {
var result = '';
var length = bytearray.length;
for (var i = 0;i < length;++i) {
result += ByteArray._HexTable[bytearray[i]];
}
return result;
};
var array = [];
for (var i = 0;i < 256;++i) {
array.push(i);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
ByteArray.ToHexStr List Join |
| ready |
ByteArray.ToHexStr String Concat |
| ready |
ByteArray.ToHexStr Static Table |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.