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
Core = function () { var moduleData = {}, debug = false; var loader = $("#loadingMsg"); //jQuery('<div style="width:100%;text-align:center; position: absolute; padding-top:2px;opacity: 0.5; color: #000; background-color: #fff; z-index:10000;">Loading...</div>'); function createInstance(moduleId) { var instance = moduleData[moduleId].creator(new Sandbox(this)), name, method; if (!debug) { for (name in instance) { method = instance[name]; if (typeof method == "function") { instance[name] = function (name, method) { return function () { try { return method.apply(this, arguments); } catch (ex) { window.console && console.log(1, name + "(): " + ex.message); } }; } (name, method); } } } return instance; };
return {
register: function (moduleId, creator) {
moduleData[moduleId] = {
creator: creator,
instance: null
};
},
start: function (moduleId) {
moduleData[moduleId].instance = createInstance(moduleId);
moduleData[moduleId].instance.init();
},
stop: function (moduleId) {
var data = moduleData[moduleId];
if (data.instance) {
data.instance.destroy();
data.instance = null;
}
},
startAll: function () {
for (var moduleId in moduleData) {
if (moduleData.hasOwnProperty(moduleId)) {
this.start(moduleId);
}
}
$.publish("AfterModulesInitialized");
},
stopAll: function () {
$.publish("BeforeModulesTearOff");
for (var moduleId in moduleData) {
if (moduleData.hasOwnProperty(moduleId)) {
this.stop(moduleId);
}
}
},
ajaxRequest: function (args) {
loader.show();
$.ajax({ url: args.url,
dataType: 'json',
data: args.data,
type: args.type,
contentType: args.contentType,
cache: false,
success: args.success,
complete: function () {
loader.hide();
}
});
},
publishEvent: function (name, args) {
$.publish(name, args);
},
subscribeEvent: function (name, func) {
$.subscribe(name, func);
},
goBack: function () {
window.history.back();
}
}
} ();
function Sandbox(core) { this.Core = core;
this.publish = function (name, args) {
Core.publishEvent(name, args);
};
this.subscribe = function (name, func) {
Core.subscribeEvent(name, func);
};
this.request = function (args) {
Core.ajaxRequest(args);
};
this.goBack = function () {
Core.goBack();
}
}
var homePageModule = function (sandbox) {
var showHomePageResults = function (args) {
var requestArgs = [];
requestArgs.url = "Home/HomePage";
sandbox.publish("command", [requestArgs]);
};
return {
init: function () {
sandbox.subscribe("home", showHomePageResults);
},
destroy: function () {
}
}
}
var formsModule = function (sandbox) { var newForm = function (args) { var requestArgs = []; if (args['table'] === undefined) { alert("Invalid command table information missing"); return false; } requestArgs.url = "form/new?table=" + args['table'] + "&form=" + (args['form'] || ""); sandbox.publish("command", [requestArgs]); };
var showForm = function (args) {
var requestArgs = [];
if (args['table'] === undefined || args['record'] === undefined) {
alert("Invalid command table and/or record information missing");
return false;
}
requestArgs.url = "form/new?table=" + args['table'] + "&form=" + (args['form'] || "") + "&recordId=" + args['record'];
sandbox.publish("command", [requestArgs]);
};
var formInitialize = function () {
$(".pivTabContainer").tabs();
$(".pivAccordion").accordion();
$(".pivControlContainer").each(function () {
var $this = $(this), inputWidth, labelWidth;
if (this.hasAttribute("data-labelWidth") === false) {
//" has no alt attribute"; do nothing
}
else if ($this.attr("data-labelWidth") === "") {
//" has an empty alt attribute"; do nothing
}
else {
$(this).find("label").width($this.attr("data-labelWidth") + "em");
}
if (this.hasAttribute("data-inputWidth") === false) {
//" has no alt attribute"; do nothing
}
else if ($this.attr("data-inputWidth") === "") {
//" has an empty alt attribute"; do nothing
}
else {
$(this).find("input").width($this.attr("data-inputWidth") + "em");
$(this).find("select").width($this.attr("data-inputWidth") + "em");
}
});
$(".pivForeignKey select").foreignkey();
$(".pivPhone").pivPhone();
$(".pivEmail").pivEmail();
$.validator.setDefaults({
// errorContainer: "#messageBox1, #messageBox2",
// errorLabelContainer: "#messageBox1 ul",
// wrapper: "li", debug: true
showErrors: function (errorMap, errorList) {
//do nothing
}
});
$.validator.unobtrusive.parse("#content form");
$(".pivForm :input:disabled").addClass("ui-state-disabled");
$(".pivForm :input:[readonly='readonly']").addClass("ui-state-disabled");
};
var formSave = function () {
window.console && console.log("form save called");
var options = {
//target: '#output2', // target element(s) to be updated with server response
//beforeSubmit: showRequest, // pre-submit callback
//success: showResponse // post-submit callback
// other available options:
url: 'form/save', // override for form's 'action' attribute
type: 'post' // 'get' or 'post', override for form's 'method' attribute
//dataType: null // 'xml', 'script', or 'json' (expected server response type)
//clearForm: true // clear all form fields after successful submit
//resetForm: true // reset the form after successful submit
// $.ajax options can be used here too, for example:
//timeout: 3000
};
//$(".pivForm").ajaxSubmit(options);
var formNode = $("#content form");
var result = formNode.valid();
if (result) {
var formValues = formNode.formSerialize();
var requestArgs = [];
requestArgs.url = 'form/save';
requestArgs.data = formValues;
requestArgs.type = "POST";
sandbox.publish("command", [requestArgs]);
}
else {
alert("Cannot save form with validation errors.");
}
};
return {
init: function () {
sandbox.subscribe("forms/new/", newForm);
sandbox.subscribe("formInit", formInitialize);
sandbox.subscribe("formSave", formSave);
sandbox.subscribe("forms/show/", showForm);
//add images required for form
$("<img src='./Images/spyGlassSearch.png'/>").hide().appendTo("body");
//use jQuery Ui Date Picker for Date Controls
$('input.pivDate:not([readonly])').live('click', function () {
$(this).datepicker({ showOn: 'focus', dateFormat: 'dd/MM/yy' }).focus();
});
},
destroy: function () {
}
}
};
var reportsModule = function (sandbox) { var showReportOptions = function (args) { var requestArgs = []; if (args['report'] === undefined) { alert("Invalid command report information missing"); return false; } requestArgs.url = 'report/show?report=' + args['report'] + '&table=' + args['table'];
sandbox.publish("command", [requestArgs]);
};
var closeReportWindow = function () {
var windowHandle = $("#reportOptionsWindow")
var window = windowHandle.data("tWindow");
window && window.close();
windowHandle && windowHandle.remove();
};
return {
init: function () {
sandbox.subscribe("report/show", showReportOptions);
$(".runRptBtn").live('click', function () {
var formNode = $("form.reportOptForm");
var formValues = formNode.formSerialize();
var requestArgs = [];
requestArgs.url = 'report/run';
requestArgs.data = formValues;
requestArgs.type = "POST";
sandbox.publish("command", [requestArgs]);
closeReportWindow();
});
$(".cancelBtn").live('click', function () {
closeReportWindow();
sandbox.goBack();
});
},
destroy: function () {
}
}
};
Core.register("formsModule", formsModule); Core.register("report", reportsModule); Core.register("homePageModule", homePageModule); Core.startAll();
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
test3 |
| ready |
test4 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.