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>
function getLastElement(n)
{
var x = n.lastChild;
while (x && x.nodeType != 1)
x = x.previousSibling;
return x;
}
function getFirstElement(n)
{
var x = n.firstChild;
while (x && x.nodeType != 1)
x = x.nextSibling;
return x;
}
function getPrevElement(n)
{
var x = n.previousSibling;
while(x && x.nodeType != 1)
x = x.previousSibling;
return x;
}
function getNextElement(n)
{
var x = n.nextSibling;
while(x && x.nodeType != 1)
x = x.nextSibling;
return x;
}
function loadXml(data) {
var self = this, xml, tmp;
if (!data) {
return null;
}
try {
//Needed to parse Model to Xml (Serializer#objectToXml).
data = data.replace(/(\r\n)/g, '
');
data = data.replace(/(\r)/g, '
');
data = data.replace(/(\n)/g, '
');
if (true) { //IE
xml = createDocument();
xml.loadXML(data);
} else { // Standard
tmp = new DOMParser();
xml = tmp.parseFromString(data, 'text/xml');
}
} catch (e) {
xml = undefined;
}
if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) {
throw 'Could not parse XML:\n' + data;
}
return getFirstElement(xml);
}
function unloadXml(xml) {
var documentElement = xml && (xml.ownerDocument || xml).documentElement;
if (documentElement && documentElement.firstChild) {
documentElement.removeChild(documentElement.firstChild);
}
}
function createDocument() {
var xmlDocument, tmp;
if (false) {
xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
xmlDocument.async = false;
xmlDocument.validateOnParse = false;
xmlDocument.resolveExternals = false;
xmlDocument.preserveWhiteSpace = true; //AvD: used for getting .text for notes
xmlDocument.setProperty('SelectionLanguage', 'XPath');
} else {
tmp = new DOMParser();
xmlDocument = tmp.parseFromString('<x/>', 'text/xml');
}
return xmlDocument;
}
function createElement(doc, tagName) {
if (doc instanceof Element) {
doc = doc.ownerDocument;
}
return doc.createElement(tagName);
}
function addChildNode(xml, tagname, attributes, value) {
var child = xml.ownerDocument.createElement(tagname);
xml.appendChild(child);
if (value) {
var text = xml.ownerDocument.createTextNode(value);
child.appendChild(text);
}
if (attributes) {
for (var attributeName in attributes) {
if(attributes[attributeName]!=null) {
child.setAttribute(attributeName, attributes[attributeName]);
}
}
}
return child;
}
function removeNodes(xpath, xml, variables) {
var nodes = XPathCache.selectNodes(xpath, xml, variables)
var toRemove = [];
for (var i = 0; i < nodes.length; i++)
toRemove.push(nodes[i]);
for (var i = 0; i < toRemove.length; i++)
toRemove[i].parentNode.removeChild(toRemove[i]);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
loadXml |
| ready |
jquery.parseXML |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.