mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 14:45:29 +00:00
91e65e3be8
Source-Repo: https://github.com/servo/servo Source-Revision: da2ea385bad2f9c22c1dc75bd52b32206cf9d9bb
71 lines
1.8 KiB
HTML
71 lines
1.8 KiB
HTML
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<script>
|
|
var ITERATIONS = 100000;
|
|
|
|
var tests = {
|
|
testGetLabelString: function() {
|
|
var label = document.getElementById("lb");
|
|
for (var i=0; i<ITERATIONS; ++i) {
|
|
var str = label.textContent;
|
|
}
|
|
},
|
|
|
|
testGetLabelNumber: function() {
|
|
var label = document.getElementById("lb");
|
|
for (var i=0; i<ITERATIONS; ++i) {
|
|
var str = label.nodeType;
|
|
}
|
|
},
|
|
|
|
testSetLabel: function() {
|
|
var label = document.getElementById("lb");
|
|
for (var i=0; i<ITERATIONS; ++i) {
|
|
label.innerHTML = "Test string new";
|
|
}
|
|
},
|
|
|
|
testCallSimpleMethod: function() {
|
|
var label = document.getElementById("lb");
|
|
for (var i=0; i<ITERATIONS; ++i) {
|
|
label.blur();
|
|
}
|
|
},
|
|
|
|
testCallMethodReturnValue: function() {
|
|
var label = document.getElementById("lb");
|
|
for (var i=0; i<ITERATIONS; ++i) {
|
|
document.adoptNode(label);
|
|
}
|
|
},
|
|
|
|
testEventObjectCreation: function() {
|
|
for (var i=0; i<ITERATIONS; ++i) {
|
|
var event = new Event('build');
|
|
}
|
|
}
|
|
};
|
|
|
|
function runTests() {
|
|
var res = document.getElementById("results");
|
|
res.innerHTML = '';
|
|
for (t in tests) {
|
|
var beginTime = performance.now();
|
|
tests[t]();
|
|
var endTime = performance.now();
|
|
var diff = ((endTime - beginTime) / ITERATIONS * 1000000).toFixed(0);
|
|
res.innerHTML = res.innerHTML + t + ": " + diff + " ns<br>";
|
|
}
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
|
|
<body onload="runTests()">
|
|
<label id="lb">Test string</label> <br>
|
|
<h1>Results:</h1>
|
|
<div id="results">Processing...</div>
|
|
</body>
|
|
</html>
|