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>
// Based on https://git.wikimedia.org/raw/mediawiki%2Fcore.git/HEAD/resources%2Fsrc%2Fmediawiki%2Fmediawiki.js
(function($) {
'use strict';
var mw,
hasOwn = Object.prototype.hasOwnProperty,
slice = Array.prototype.slice;
function Map(values) {
this.values = values === true ? window : (values || {});
return this;
}
Map.prototype = {
get: function(selection, fallback) {
var results, i;
// If we only do this in the `return` block, it'll fail for the
// call to get() from the mutli-selection block.
fallback = arguments.length > 1 ? fallback : null;
if ($.isArray(selection)) {
selection = slice.call(selection);
results = {};
for (i = 0; i < selection.length; i++) {
results[selection[i]] = this.get(selection[i], fallback);
}
return results;
}
if (typeof selection === 'string') {
if (!hasOwn.call(this.values, selection)) {
return fallback;
}
return this.values[selection];
}
if (selection === undefined) {
return this.values;
}
// invalid selection key
return null;
},
/**
* Sets one or multiple key/value pairs.
*
* @param {string|Object} selection String key to set value for, or object mapping keys to values.
* @param {Mixed} [value] Value to set (optional, only in use when key is a string)
* @return {Boolean} This returns true on success, false on failure.
*/
set: function(selection, value) {
var s;
if ($.isPlainObject(selection)) {
for (s in selection) {
this.values[s] = selection[s];
}
return true;
}
if (typeof selection === 'string' && arguments.length > 1) {
this.values[selection] = value;
return true;
}
return false;
}
};
mw = {
Map: Map
};
mw.config = new mw.Map(true);
mw.config.set({
"A": "a",
"B": "b",
"C": "c"
});
window.mw = mw;
}(jQuery));
Ready to run.
Test | Ops/sec | |
---|---|---|
Single variable |
| ready |
No variable |
| ready |
Multiple variables |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.