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 src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://documentcloud.github.com/underscore/underscore.js"></script>
<script>
(function(window) {
var hasOwnProperty = {}.hasOwnProperty,
toString = {}.toString;
_.mixin({
// Is a given variable an arguments object?
isArgumentsNew: toString.call(arguments) == '[object Arguments]'
? function(obj) {
return toString.call(obj) == '[object Arguments]';
}
: function(obj) {
return !!(obj && hasOwnProperty.call(obj, 'callee'));
},
// Is a given value a function?
isFunctionNew: function(obj) {
return toString.call(obj) == '[object Function]';
},
// Is a given value a string?
isStringNew: function(obj) {
return toString.call(obj) == '[object String]';
},
// Is a given value a number?
isNumberNew: function(obj) {
return toString.call(obj) == '[object Number]';
},
// Is a given value a date?
isDateNew: function(obj) {
return toString.call(obj) == '[object Date]';
},
// Is the given value a regular expression?
isRegExpNew: function(obj) {
return toString.call(obj) == '[object RegExp]';
}
});
window._typeof = {
// Is a given value a function?
isFunction: function(obj) {
return typeof obj == 'function';
},
// Is a given value a string?
isString: function(obj) {
return typeof obj == 'string';
},
// Is a given value a number?
isNumber: function(obj) {
return typeof obj == 'number';
},
// Is a given value a date?
isDate: function(obj) {
return obj instanceof Date;
},
// Is the given value a regular expression?
isRegExp: function(obj) {
return obj instanceof RegExp;
}
};
window._constructor = {
// Is a given value a function?
isFunction: function(obj) {
return obj ? obj.constructor.name === 'Number' : false;
},
// Is a given value a string?
isString: function(obj) {
return obj ? obj.constructor.name === 'String' : false;
},
// Is a given value a number?
isNumber: function(obj) {
return obj ? obj.constructor.name === 'Number' : false;
},
// Is a given value a date?
isDate: function(obj) {
return obj ? obj.constructor.name === 'Date' : false;
},
// Is the given value a regular expression?
isRegExp: function(obj) {
return obj ? obj.constructor.name === 'RegExp' : false;
}
};
}(window));
window._instance = (function () {
function _isType (type) {
return function (o) {
return (typeof o === type);
};
}
function _instanceOf (_constructor) {
return function (o) {
return ( o instanceof _constructor );
};
}
return {
isFunction: _instanceOf(Function),
isString: _isType('string'),
isNumber: _instanceOf(Number),
isDate: _instanceOf(Date),
isRegExp: _instanceOf(RegExp)
};
})();
window._curry = (function () {
function _isType (curryType) {
function checkType(type) {
return (type === curryType)
}
return function (o) {
return checkType(typeof o);
};
}
function _instanceOf (_constructor) {
return function (o) {
return ( o instanceof _constructor );
};
}
return {
isFunction: _isType('function'),
isString: _isType('string'),
isNumber: _isType('number'),
isDate: _instanceOf(Date),
isRegExp: _instanceOf(RegExp)
};
})();
</script>
var $ = window.jQuery,
_ = window._,
array = [1, 2, 3],
func = function(){},
string = "string",
number = 101,
date = new Date,
regexp = /regexp/i;
Ready to run.
Test | Ops/sec | |
---|---|---|
Proposed Implementation |
| ready |
Sanity Check |
| ready |
typeof |
| ready |
constructor.name |
| ready |
instanceof |
| ready |
curry |
| ready |
Current Implementation |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.