Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: third_party/WebKit/Source/benchmarks/html-benchmark.html

Issue 2197923002: Not for landing: Profile Elliott's parsing benchmark Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: temp Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/benchmarks/html-benchmark.html
diff --git a/third_party/WebKit/Source/benchmarks/html-benchmark.html b/third_party/WebKit/Source/benchmarks/html-benchmark.html
new file mode 100644
index 0000000000000000000000000000000000000000..68b26961d67e04a3bb6bf42d790e2535ee99e11f
--- /dev/null
+++ b/third_party/WebKit/Source/benchmarks/html-benchmark.html
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+
+<style>
+section {
+ border: 2px solid red;
+ margin: 16px;
+ padding: 8px;
+}
+</style>
+
+<script src="dom/bindings/realdomparserbindings.js"></script>
+<script src="dom/bindings/fakedomparserbindings.js"></script>
+<script src="dom/domparser.js"></script>
+
+<script>
+var multipler = 1;
+
+var output = document.getElementById("output");
+
+var xhr = new XMLHttpRequest();
+xhr.open("GET", "wikipedia-markup.txt");
+xhr.responseType = "text";
+
+function treeSize(node) {
+ var count = 0;
+ for (var child = node.firstChild; child; child = child.nextSibling)
+ count += 1 + treeSize(child);
+ return count;
+}
+
+function benchmarkParser(name, callback) {
+ document.body.focus();
+ benchmarkParserInternal(name, callback);
+ document.body.blur();
+ gc(); gc(); gc();
+}
+
+function benchmarkParserInternal(name, callback) {
+ var section = document.createElement("section");
+ var startTime = Date.now();
+ var timeRecord = callback();
+ var time = Date.now() - startTime;
+ var output = name + " time: " + time + "ms, createElement: " + timeRecord["createElement"] + "ms, createText: " + timeRecord["createText"] + "ms, appendChild: " + timeRecord["appendChild"] + "ms, setAttribute: " + timeRecord["setAttribute"] + "ms";
+ section.appendChild(document.createTextNode(output));
+ document.body.appendChild(section);
+}
+
+xhr.onload = function() {
+ var markup = "";
+ for (var i = 0; i < multipler; i++)
+ markup += xhr.responseText;
+
+ for (var i = 0; i < 10; i++) {
+ benchmarkParser("innerHTML", function() {
+ element = document.createElement("template");
+ element.innerHTML = markup;
+ return {};
+ });
+ }
+
+ for (var i = 0; i < 10; i++) {
+ benchmarkParser("Real bindings", function() {
+ var parser = new DomParser(markup, RealDomParserBindings);
+ return parser.parse();
+ });
+ }
+};
+
+xhr.onerror = function() {
+ console.log(xhr.status);
+};
+
+xhr.send();
+</script>
« no previous file with comments | « third_party/WebKit/Source/benchmarks/dom/domparser.js ('k') | third_party/WebKit/Source/benchmarks/test-markup.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698