-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfps.html
37 lines (36 loc) · 855 Bytes
/
fps.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style type="text/css">
body {
background-color: transparent;
}
h1 {
margin: 5px;
padding: 5px;
color: black;
background-color: lime;
}
</style>
</head>
<body>
<h1 id="h1">Loading...</h1>
<h1 id="h2"></h1>
<script type="text/javascript">
var frames = 0;
var lastTimestamp;
function step (timestamp) {
frames++;
if (lastTimestamp) {
var fps = 1000 / (timestamp - lastTimestamp);
document.getElementById("h1").innerHTML = 'frames: ' + frames;
document.getElementById("h2").innerHTML = 'fps: ' + fps.toFixed(2);
}
lastTimestamp = timestamp;
window.requestAnimationFrame(step);
};
window.requestAnimationFrame(step);
</script>
</body>
</html>