aboutsummaryrefslogtreecommitdiffstats
path: root/tests/html/bindings_perf.html
blob: 123c53d6c00244e05495b70060a24f6b227f2f73 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<button onclick="void_method()">measure void method</button>
<button onclick="int_getter()">measure int getter</button>
<button onclick="firstChild_getter()">measure firstChild getter</button>
<button onclick="proxy_firstChild_getter()">measure proxy 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');
}

function proxy_firstChild_getter() {
  var n = document;
  var start = new Date();
  var count = 1000000;
  for (var i = 0; i < count; i++) {
    var a = n.firstChild;
  }
  var stop = new Date();
  console.log('proxy firstChild getter: ' + ((stop - start) / count * 1e6) + 'ns');
}
</script>