OLD | NEW |
| (Empty) |
1 (function(){ | |
2 | |
3 var framesPerTimerReading = 10; | |
4 var frameCount = 0; | |
5 var startTime; | |
6 var trackingFrameRate = false; | |
7 var currentTest; | |
8 | |
9 function trackFrameRate(currTime) | |
10 { | |
11 if (++frameCount == framesPerTimerReading) { | |
12 frameCount = 0; | |
13 PerfTestRunner.measureValueAsync(1000 * framesPerTimerReading / (currTim
e - startTime)); | |
14 startTime = currTime; | |
15 } | |
16 | |
17 if (currentTest && currentTest.run) | |
18 currentTest.run(); | |
19 | |
20 if (trackingFrameRate) | |
21 requestAnimationFrame(trackFrameRate); | |
22 } | |
23 | |
24 window.startTrackingFrameRate = function(test) { | |
25 if (trackingFrameRate) | |
26 return; | |
27 trackingFrameRate = true; | |
28 currentTest = test; | |
29 startTime = performance.now(); | |
30 trackFrameRate(); | |
31 }; | |
32 | |
33 window.stopTrackingFrameRate = function() { | |
34 trackingFrameRate = false; | |
35 currentTest = undefined; | |
36 }; | |
37 | |
38 })(); | |
OLD | NEW |