-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
65 lines (55 loc) · 1.63 KB
/
index.html
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<script src="performance_observer_tracing.js"></script>
<script>
function download(filename, text) {
const blob = new Blob([text], {type: 'text/plain'});
var element = document.createElement('a');
element.setAttribute('href', window.URL.createObjectURL(blob));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
function downloadTrace() {
download('performance_observer_trace.json',
JSON.stringify(window.getPerformanceObserverTrace()));
}
window.addEventListener("load", function() {
document.addEventListener("click", function() {
let now = performance.now();
performance.mark("ClickAStart");
while (performance.now() < now + 500){}
performance.mark("ClickAEndBStart");
now = performance.now();
while (performance.now() < now + 500){}
performance.mark("ClickBEnd");
performance.measure("ClickA", "ClickAStart", "ClickAEndBStart");
performance.measure("ClickB", "ClickAEndBStart", "ClickBEnd");
});
});
function fetchResource() {
var oReq = new XMLHttpRequest();
oReq.open('get', 'https://thecatapi.com/api/images/get?format=src&type=gif', true);
oReq.send();
}
</script>
<style>
#box {
width:50px;
height:50px;
background-color:blue;
}
#box:hover {
background-color:red;
}
</style>
</head>
<body>
<div id="box" report-styleupdate></div>
<div class="button"> <a href="#" onclick="fetchResource()">Fetch Resource</a> </div>
<div class="button"> <a href="#" onclick="downloadTrace()">Download Trace</a> </div>
</body>
</html>