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 censor(censor) {
var i = 0;
return function(key, value) {
if(i !== 0 && typeof(censor) === 'object' && typeof(value) == 'object' && censor == value)
return '[Circular]';
if(i >= 29) // seems to be a harded maximum of 30 serialized objects?
return '[Unknown]';
++i; // so we know we aren't using the original object anymore
return value;
}
}
Object.prototype.GetHashCode = function () {
var s = this instanceof Object ? JSON.stringify(this, censor(this)) : this.toString();
var hash = 0;
if (s.length === 0) return hash;
for (var i = 0; i < s.length; ++i) {
hash = ((hash << 5) - hash) + s.charCodeAt(i);
}
return hash;
};
function hashString(s)
{
var hash = 0;
if (s.length === 0) return hash;
for (var i = 0; i < s.length; ++i) {
hash = ((hash << 5) - hash) + s.charCodeAt(i);
}
return hash;
}
function hashCode4(obj, profundidade) {
if ( !profundidade) profundidade= 0;
var hash = 0;
for ( var p in obj )
hash += hashString(p) +
(profundidade> 0 ? hashCode4(obj[p], profundidade-1) : 0);
return hash;
}
var example = { ID: 1, Items: [ { Name: "X" }, { Name: "Y" } ] };
var exemploEnorme1 = { valor:1, texto:"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." }
var exemploEnorme2 = { valor:2, texto:"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." }
var exemploEnorme3 = { valor:1, texto:"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit este cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." }
var exemploSemTexto1 = { 1:2, 3:4, 5:6, 7:8, 9:10,
11:12, 13:14, 15:16, 17:18, 19:20,
21:22, 23:24, 25:26, 27:28, 29:30,
31:32, 33:34, 35:36, 37:38, 39:40,
41:42, 43:44, 45:46, 47:48, 49:50 };
var exemploSemTexto2 = { 1:987654321, 2:9.87654321 };
Ready to run.
Test | Ops/sec | |
---|---|---|
GetHashCode |
| ready |
hashCode4 prof 0 |
| ready |
hashCode4 prof 1 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.