Add a manual test for measuring DOM binding performance

This commit is contained in:
Josh Matthews 2016-07-14 16:00:47 -04:00 committed by GitHub
parent 48a912f57e
commit fb7772db1a

View file

@ -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>