tests: Vendor blink perf tests (#38654)

Vendors the [blink perf
tests](https://chromium.googlesource.com/chromium/src/+/HEAD/third_party/blink/perf_tests/).
These perf tests are useful to evaluate the performance of servo. 
The license that governs the perf tests is included in the folder. 
Running benchmark cases automatically is left to future work.

The update.py script is taken from mozjs and slightly adapted, so we can
easily filter
(and patch if this should be necessary in the future.

Testing: This PR just adds the perf_tests, but does not use or modify
them in any way.

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender 2025-08-17 11:54:04 +02:00 committed by GitHub
parent 7621332824
commit ee781b71b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
648 changed files with 359694 additions and 0 deletions

View file

@ -0,0 +1 @@
mixins: "//third_party/blink/renderer/core/html/parser/COMMON_METADATA"

View file

@ -0,0 +1 @@
file://third_party/blink/renderer/core/html/parser/OWNERS

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,71 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
function createDeepShadowTemplateContent(levels, slotted) {
const nestedContent = levels > 0 ? createDeepShadowTemplateContent(levels-1) : '<span>End</span>';
if (slotted) {
return `<div><template shadowrootmode=open serializable><slot></slot></template>${nestedContent}</div>`;
} else {
return `<div><template shadowrootmode=open serializable>${nestedContent}</template></div>`;
}
}
const hostChildren = 100;
// Make sure the clone operation works
function testClone(template) {
const wrapper = document.createElement('div');
document.body.appendChild(wrapper);
wrapper.appendChild(template.content.cloneNode(true));
const templateHtml = template.getHTML({serializableShadowRoots: true});
const clonedHtml = wrapper.getHTML({serializableShadowRoots: true});
if (templateHtml !== clonedHtml) {
PerfTestRunner.logFatalError('Cloned template does not match original!');
}
wrapper.remove();
}
function buildTemplate(slotted) {
const template = document.createElement('template');
document.body.appendChild(template);
const html = createDeepShadowTemplateContent(hostChildren, slotted);
template.content.setHTMLUnsafe(html);
testClone(template);
return template;
}
// Build templates once
const templateSlotted = buildTemplate(true);
const templateNested = buildTemplate(false);
if (!templateSlotted.content.firstChild.shadowRoot) {
PerfTestRunner.logFatalError("Declarative Shadow DOM must be enabled for this test.");
}
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests cloning of templates containing declarative Shadow DOM",
setup: function() {
const wrapper = document.createElement('div');
wrapper.id = 'wrapper';
document.body.appendChild(wrapper);
},
run: function() {
const wrapper = document.querySelector('#wrapper');
for (var i = 0; i < 100; i++) {
wrapper.appendChild(templateSlotted.content.cloneNode(true));
wrapper.appendChild(templateNested.content.cloneNode(true));
}
},
teardown: function() {
wrapper.remove();
}});
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<body>
<pre id="log"></pre>
<div id=host></div>
<script src="../resources/runner.js"></script>
<script src="../shadow_dom/resources/declarative.js"></script>
<script>
const shadowHtml = getShadowMarkup(true, /*depth=*/4, /*copies=*/100);
const host = document.getElementById('host');
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests declarative Shadow DOM attachment",
run: function() {
host.replaceChildren();
parseAndAppend(host,shadowHtml);
}
});
</script>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<body>
<script src="../resources/runner.js"></script>
<script>
var spec = PerfTestRunner.loadFile("resources/html5.html");
PerfTestRunner.measureTime({
description: "Measures performance of the HTML parser.",
run: function() {
var iframe = document.createElement("iframe");
iframe.style.display = "none"; // Prevent creation of the rendering tree, so we only test HTML parsing.
iframe.sandbox = 'allow-same-origin'; // Prevent external script loads which could cause write() to return before completing the parse.
document.body.appendChild(iframe);
iframe.contentDocument.open();
iframe.contentDocument.write(spec);
iframe.contentDocument.close();
document.body.removeChild(iframe);
}
});
</script>
</body>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<body>
<script src="../resources/runner.js"></script>
<script>
// Running from the onload callback just makes the UI nicer as it shows the logs before starting the test.
window.onload = function() {
PerfTestRunner.measurePageLoadTime({
description: "Measures performance of a full HTML5 document load.",
path: "resources/html5.html",
// 6.09mb / 500k = approx 13 chunks (thus 13 forced layouts/style resolves).
chunkSize: 500000
});
};
</script>
</body>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests adding/removing an iframe from the DOM",
run: function() {
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
document.body.removeChild(iframe);
}});
</script>
</body>
</html>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
// Taken from http://jsperf.com/parse-html-type
// The major difference between this test and innerHTML-setter.html
// is that innerHTML-setter creates a single root node
// which avoids some of the costs in transplating nodes from the
// intermediary DocumentFragment to its final parent.
var tags = '<div></div><div></div><div></div><div></div><div></div>';
var attr = '<div foo="bar" foo="bar" foo="bar" foo="bar sda"></div>';
var nest = '<div><div><div><div><div></div></div></div></div></div>';
var tags10 = tags + tags + tags + tags + tags + tags + tags + tags + tags + tags;
var attr10 = attr + attr + attr + attr + attr + attr + attr + attr + attr + attr;
var nest10 = nest + nest + nest + nest + nest + nest + nest + nest + nest + nest;
var div = document.createElement('div');
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests innerHTML setter for a large DOM tree",
run: function() {
div.innerHTML = tags10;
div.innerHTML = attr10;
div.innerHTML = nest10;
div.innerHTML = "";
}});
</script>
</body>
</html>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
function generateBinDOMTree(depth) {
return depth == 0 ? "text" : ("<div>" + generateBinDOMTree(depth - 1) + generateBinDOMTree(depth - 1) + "</div>");
}
var div = document.createElement("div");
document.body.appendChild(div);
var tree = generateBinDOMTree(10);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests innerHTML setter for a large DOM tree",
run: function() {
div.innerHTML = tree;
div.innerHTML = "";
}});
</script>
</body>
</html>

View file

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<body>
<div class="foo" bar="baz">
<div class="foo" bar="baz">
<div class="foo" bar="baz">
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
</div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
</div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
</div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<script src="../resources/runner.js"></script>
<script>
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() on complex attributes",
run: function() {
for (var i = 0; i < 1000; i++) {
document.querySelectorAll("[bar^=baz]");
document.querySelectorAll("[bar*=baz]");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<body>
<div class="foo" bar="baz">
<div class="foo" bar="baz">
<div class="foo" bar="baz">
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
</div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
</div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
</div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<script src="../resources/runner.js"></script>
<script>
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() on attributes",
run: function() {
for (var i = 0; i < 1000; i++) {
document.querySelectorAll("[bar^=baz]");
document.querySelectorAll("[bar*=baz]");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
var parentDiv = document.body;
for (var i = 0; i < 500; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
parentDiv.appendChild(div);
parentDiv = div;
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
parentDiv.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() for an element that appears in the depths in the document, and is a descendant of an element with a given class name",
run: function() {
for (var i = 0; i < 100; i++) {
var res = document.querySelectorAll(".bar998 h1");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<body>
<h1 id="id" class="class"></h1>
<script src="../resources/runner.js"></script>
<script>
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() for an element that appears near the head of the document",
run: function() {
for (var i = 0; i < 1000; i++) {
document.querySelectorAll(".class");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
for (var i = 0; i < 1000; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
document.body.appendChild(div);
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
document.body.lastChild.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() for an element that appears near the tail of the document, and is a child of an element with a given id",
run: function() {
for (var i = 0; i < 100; i++) {
var res = document.querySelectorAll(".bar999 > h1");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<body>
<div class="foo" bar="baz">
<div class="foo" bar="baz">
<div class="foo" bar="baz">
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
</div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
</div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
</div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<div class="foo" bar="baz"></div>
<script src="../resources/runner.js"></script>
<script>
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() on classes",
run: function() {
for (var i = 0; i < 1000; i++) {
document.querySelectorAll(".foo");
document.querySelectorAll("div.foo");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
var parentDiv = document.body;
for (var i = 0; i < 500; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
parentDiv.appendChild(div);
parentDiv = div;
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
parentDiv.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() for an element that appears in the depths in the document",
run: function() {
for (var i = 0; i < 100; i++) {
document.querySelectorAll("h1");
document.querySelectorAll("#id");
document.querySelectorAll(".class");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<body>
<h1 id="id" class="class"></h1>
<script src="../resources/runner.js"></script>
<script>
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() for an element that appears near the head of the document",
run: function() {
for (var i = 0; i < 1000; i++) {
document.querySelectorAll("h1");
document.querySelectorAll("#id");
document.querySelectorAll(".class");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
var parentDiv = document.body;
for (var i = 0; i < 500; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
parentDiv.appendChild(div);
parentDiv = div;
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
parentDiv.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() for an element that appears in the depths in the document, and is a descendant of an element with a given id",
run: function() {
for (var i = 0; i < 100; i++) {
var res = document.querySelectorAll("#foo998 h1");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<body>
<h1 id="id" class="class"></h1>
<script src="../resources/runner.js"></script>
<script>
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() for an element that appears near the head of the document",
run: function() {
for (var i = 0; i < 1000; i++) {
document.querySelectorAll("#id");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
for (var i = 0; i < 1000; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
document.body.appendChild(div);
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
document.body.lastChild.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() for an element that appears near the tail of the document, and is a child of an element with a given id",
run: function() {
for (var i = 0; i < 100; i++) {
var res = document.querySelectorAll("#foo999 > h1");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
for (var i = 0; i < 1000; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
document.body.appendChild(div);
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
document.body.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelectorAll() for an element that appears near the tail of the document",
run: function() {
for (var i = 0; i < 100; i++) {
document.querySelectorAll("h1");
document.querySelectorAll("#id");
document.querySelectorAll(".class");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
var parentDiv = document.body;
for (var i = 0; i < 100; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
parentDiv.appendChild(div);
parentDiv = div;
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
parentDiv.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelector() for an element that appears in the depths in the document",
run: function() {
for (var i = 0; i < 100; i++) {
document.querySelector("h1");
document.querySelector("#id");
document.querySelector(".class");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<body>
<h1 id="id" class="class"></h1>
<script src="../resources/runner.js"></script>
<script>
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelector() for an element that appears near the head of the document",
run: function() {
for (var i = 0; i < 1000; i++) {
document.querySelector("h1");
document.querySelector("#id");
document.querySelector(".class");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
var parentDiv = document.body;
for (var i = 0; i < 100; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
parentDiv.appendChild(div);
parentDiv = div;
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
parentDiv.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelector() for an element that appears in the depths in the document, and is a descendant of an element with a given id",
run: function() {
for (var i = 0; i < 100; i++) {
var res = document.querySelector("#foo98 h1");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
for (var i = 0; i < 1000; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
document.body.appendChild(div);
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
document.body.lastChild.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelector() for an element that appears near the tail of the document, and is a child of an element with a given id",
run: function() {
for (var i = 0; i < 100; i++) {
var res = document.querySelector("#foo999 > h1");
}
}});
</script>
</body>
</html>

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
for (var i = 0; i < 1000; i++) {
var div = document.createElement("div");
div.id = "foo" + i;
div.className = "bar" + i;
document.body.appendChild(div);
}
var h1 = document.createElement("h1");
h1.id = "id";
h1.className = "class";
document.body.appendChild(h1);
PerfTestRunner.measureRunsPerSecond({
description: "This benchmark tests querySelector() for an element that appears near the tail of the document",
run: function() {
for (var i = 0; i < 100; i++) {
document.querySelector("h1");
document.querySelector("#id");
document.querySelector(".class");
}
}});
</script>
</body>
</html>

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<body>
<script src="../resources/runner.js"></script>
<script>
var anchor = document.createElement("a");
PerfTestRunner.measureRunsPerSecond({
description: "Measures performance of URL parsing by setting the href attribute on an <a> tag to a simple URL.",
run: function() {
for (var x = 0; x < 200000; x++) {
anchor.href = "http://www.apple.com/"
}
}
});
</script>
</body>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<body>
<style>
textarea:valid {
background-color: lime;
}
textarea:invalid {
background-color: red;
}
</style>
<script src="../resources/runner.js"></script>
<div id="container"></div>
<script>
var htmlText = "<textarea maxlength=2147483647>";
for (var i = 0; i < 1000; ++i) {
htmlText += "A quick brown fox jumps over the lazy dog.\n" +
"A quick brown fox jumps over the lazy dog.\n" +
"<!-- comment -->\n";
}
htmlText += "</textarea>"
var container = document.getElementById('container');
PerfTestRunner.measureRunsPerSecond({
description: "Measures performance of parsing within a <textarea> tag.",
run: function() {
container.innerHTML = htmlText;
}
});
</script>
</body>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<body>
<script src="../resources/runner.js"></script>
<script>
PerfTestRunner.measureRunsPerSecond({
description: "Measures performance of creating an element and setting a tiny amount of HTML.",
run: function() {
var testDiv = document.createElement("div");
testDiv.style.display = "none";
document.body.appendChild(testDiv);
for (var x = 0; x < 100000; x++) {
testDiv.innerHTML = "This is a tiny HTML document";
}
document.body.removeChild(testDiv);
}
});
</script>
</body>

View file

@ -0,0 +1,17 @@
<!DOCTYPE html>
<body>
<script src="../resources/runner.js"></script>
<script>
var urls = PerfTestRunner.loadFile("resources/final-url-en").split("\n");
var anchor = document.createElement("a");
PerfTestRunner.measureRunsPerSecond({
description: "Measures performance of URL parsing by setting the href attribute on an <a> tag to many different URLs.",
run: function() {
for (var x = 0; x < urls.length; x++) {
anchor.href = urls[x];
}
}
});
</script>
</body>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<body>
<script src="../resources/runner.js"></script>
<script>
var domParser = new DOMParser();
var xmlArray = [];
xmlArray.push('<root>');
for (var i = 0; i < 0x7FFF; ++i)
xmlArray.push('<item attribute1="value1" attribute2="value2" attribute3="value3" attribute4="value4" attribute5="value5" />');
xmlArray.push('</root>')
var xmlData = xmlArray.join('');
PerfTestRunner.measureRunsPerSecond({
description: "Measures performance of the XML parser.",
run: function() {
domParser.parseFromString(xmlData, "text/xml");
}
});
</script>
</body>