-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfps.htm
44 lines (33 loc) · 1.04 KB
/
fps.htm
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
<html>
<head>
<title></title>
<style>
html { font:system; }
</style>
<script type="text/tiscript">
function self.ready() {
var fps = new Graphics.Text("",self);
var deltas = [1];
var ptick = System.ticks;
self.paintForeground = function(gfx) {
var tick = System.ticks;
deltas.push( tick - ptick );
if( deltas.length > 10 )
deltas.shift();
ptick = tick;
var avdelta = deltas.reduce(:a,b: a + b) / deltas.length;
fps.chars = "FPS:" + (1000 / avdelta).toString();
var (w,h) = self.box(#dimension,#inner);
gfx.fillColor(color(200,100,0)).drawText(fps, w - 10, 10, 9);
};
self.animate(function() {
this.refresh(); // requests repaint on each animate tick
return true;
});
}
</script>
</head>
<body>
FPS测试器, 请看右侧的实际FPS。
</body>
</html>