mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Add a manual test for measuring DOM binding performance
This commit is contained in:
parent
48a912f57e
commit
fb7772db1a
1 changed files with 36 additions and 0 deletions
36
tests/html/bindings_perf.html
Normal file
36
tests/html/bindings_perf.html
Normal 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>
|
Loading…
Add table
Add a link
Reference in a new issue