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>
/*
{
name : "hot.core",
author : "Artem Smirnov",
version : 0.01,
provide : {
hot : {
typeof
clone
implement
type
extend
}
}
}
*/
(function (Object) {
var toString, hot, types, typeOf, clone, type, implement, extend; // Define variables
toString = Object.prototype.toString; // Define function to string
hot = this.hot = function (val) {
return new hot[typeOf(val)](val);
}; // Hight level but slow function, i will change role of this function
typeOf = hot.typeOf = function (val) {
//Try to define type using typeof
var type = typeof val;
if (typeof val !== "object") {
return type;
}
//[Object type]
type = toString.call(val).charCodeAt(8);
if (type in typeOf.types) return typeOf.types[type];
//Argument?
if (val.calee) {
return "arguments";
}
return "object";
};//Very fast typeOf
typeOf.types = [];
['Array', 'Date', 'Number', 'String', 'Boolean', 'Function', 'RegExp', 'Class'].forEach( function (name, i) {
typeOf.types[name.charCodeAt(0)] = name.toLowerCase();
});
clone = hot.clone = function (obj) {
if (obj === null || typeof(obj) != "object") {
return obj;
}
var copy = {};
for (var key in obj) {
copy[key] = clone(obj[key]);
}
return copy;
}; // Return clone of object
extend = hot.extend = function (child, parent) {
for (var key in parent) {
child[key] = parent[key];
}
}; // Add props from parent to child
type = hot.type = function (type) {
if (type.Init) {
var Constructor = type.Init;
} else {
var Constructor = function () {};
}
for (var prop in type) {
if ( type.hasOwnProperty(prop) ) {
if ("Init,Extend,Implement,Static".indexOf(prop) === -1) {
Constructor.prototype[prop] = type[prop];
}
}
}
if (type.Static) {
var Static = type.Static;
for (var prop in Static) {
if ( Static.hasOwnProperty(prop) ) {
Constructor[prop] = Static[prop];
}
}
}
if (type.Extend) {
var parent = type.Extend;
Constructor.prototype.parent = parent;
for (var prop in parent) {
if ( typeof Constructor[prop] == "undefined" ) {
Constructor[prop] = parent[prop];
}
}
for (var prop in parent.prototype) {
if ( typeof Constructor.prototype[prop] == "undefined" ) {
Constructor.prototype[prop] = parent.prototype[prop];
console.log("yaa");
}
}
}
if (type.Implement) {
var Implements = type.Implement;
Implements.forEach(function (mixin) {
for (var prop in mixin) {
if (typeof Constructor.prototype[prop] == "undefined") {
Constructor.prototype[prop] = mixin[prop];
console.log(Constructor.prototype[prop]);
}
}
});
}
//Define constructor prop
Constructor.prototype.constructor = Constructor;
//Define superclass prop
Constructor.superclass = extend;
return Constructor;
};
implement = hot.implement = function (child, parent) {
extend(child.prototype, clone(parent.prototype));
};
return hot;
})(Object);
__native = function (x) {
this.x = x;
};
__native.prototype = {
get_x : function () {
return this.x;
}
}
__hot = hot.type({
Init : function (x) {
this.x = x;
},
get_x : function () {
return this.x;
}
});
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Native |
| ready |
Hot |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.