servo: Merge #12449 - Add a manual test for measuring DOM binding performance (from servo:jdm-patch-1); r=Ms2ger
authorJosh Matthews <josh@joshmatthews.net>
Fri, 15 Jul 2016 02:21:19 -0700
changeset 339297 e4d67f5de3726158dba798aefa1ba6e7e3040dad
parent 339296 b9276f6929ab7fffda2faa73e7b9c4f13d819154
child 339298 d0becf5b5cb8829ec2817ecf26c3b3f68614057d
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
servo: Merge #12449 - Add a manual test for measuring DOM binding performance (from servo:jdm-patch-1); r=Ms2ger This is the test harness I've been using for profiling and measuring in #12354. Source-Repo: https://github.com/servo/servo Source-Revision: f2efc0011ab229718181175a2637bbc4ce70cd0c
servo/tests/html/bindings_perf.html
new file mode 100644
--- /dev/null
+++ b/servo/tests/html/bindings_perf.html
@@ -0,0 +1,36 @@
+<button onclick="void_method()">measure void method</button>
+<button onclick="int_getter()">measure int getter</button>
+<button onclick="firstChild_getter()">measure firstChild getter</button>
+<script>
+var t = 'TestBinding' in window ? (new TestBinding()) : (new TextEncoder());
+function void_method() {
+  var start = new Date();
+  var count = 1000000;
+  for (var i = 0; i < count; i++) {
+    var a = t.receiveVoid();
+  }
+  var stop = new Date();
+  console.log('void method: ' + ((stop - start) / count * 1e6) + 'ns');
+}
+
+function int_getter() {
+  var start = new Date();
+  var count = 1000000;
+  for (var i = 0; i < count; i++) {
+    var a = t.longAttribute;
+  }
+  var stop = new Date();
+  console.log('int getter: ' + ((stop - start) / count * 1e6) + 'ns');
+}
+
+function firstChild_getter() {
+  var n = document.documentElement;
+  var start = new Date();
+  var count = 100000000;
+  for (var i = 0; i < count; i++) {
+    var a = n.firstChild;
+  }
+  var stop = new Date();
+  console.log('firstChild getter: ' + ((stop - start) / count * 1e6) + 'ns');
+}
+</script>