OLD | NEW |
---|---|
1 <!-- Used by media_fps_perf to calculate <video> performance statistics. --> | 1 <!-- Used by media_stat_perf to calculate <video> performance statistics. --> |
2 | 2 |
3 <!DOCTYPE html> | 3 <!DOCTYPE html> |
4 <html lang="en-US"> | 4 <html lang="en-US"> |
5 <head> | 5 <head> |
6 <title>FPS Perf Test</title> | 6 <title>CPU, Memomry, and FPS Perf Test</title> |
DaleCurtis
2012/02/29 22:39:11
Memory
shadi
2012/03/01 02:40:53
Done.
| |
7 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <div id="log"> | 9 <div id="log"> |
10 Decoded frames: 0 Avg: 0<br> | 10 Decoded frames: 0 Avg: 0<br> |
11 Dropped frames: 0 Avg: 0<br> | 11 Dropped frames: 0 Avg: 0<br> |
12 </div> | 12 </div> |
13 <video preload controls></video> | 13 <video preload controls></video> |
14 </body> | 14 </body> |
15 | 15 |
16 <script type="text/javascript"> | 16 <script type="text/javascript"> |
17 var video = document.querySelector("video"); | 17 var video = document.querySelector("video"); |
18 | 18 |
19 var decodedFrames = 0; | 19 var decodedFrames = 0; |
20 var droppedFrames = 0; | 20 var droppedFrames = 0; |
21 var decodedFPS = []; | 21 var decodedFPS = []; |
22 var droppedFPS = []; | 22 var droppedFPS = []; |
23 var startTime = 0; | 23 var startTime = 0; |
24 var intID = 0; // interval ID, used to end the window intervals. | 24 var intID = 0; // interval ID, used to end the window intervals. |
25 var statsEnabled = false; // set to true to record FPS stats. | |
25 | 26 |
26 function calculateStats() { | 27 function calculateStats() { |
27 if (video.readyState <= HTMLMediaElement.HAVE_CURRENT_DATA || | 28 if (video.readyState <= HTMLMediaElement.HAVE_CURRENT_DATA || |
28 video.paused || video.ended) | 29 video.paused || video.ended) |
29 return; | 30 return; |
30 | 31 |
31 currentTime = new Date().getTime(); | 32 currentTime = new Date().getTime(); |
32 deltaTime = (currentTime - startTime) / 1000; | 33 deltaTime = (currentTime - startTime) / 1000; |
33 startTime = currentTime; | 34 startTime = currentTime; |
34 | 35 |
(...skipping 14 matching lines...) Expand all Loading... | |
49 "Dropped frames: " + droppedFrames + | 50 "Dropped frames: " + droppedFrames + |
50 " Avg: " + droppedFPS + " fps.<br>"; | 51 " Avg: " + droppedFPS + " fps.<br>"; |
51 } | 52 } |
52 | 53 |
53 video.addEventListener("playing", function(event) { | 54 video.addEventListener("playing", function(event) { |
54 decodedFrames = 0; | 55 decodedFrames = 0; |
55 droppedFrames = 0; | 56 droppedFrames = 0; |
56 decodedFPS = []; | 57 decodedFPS = []; |
57 droppedFPS = []; | 58 droppedFPS = []; |
58 startTime = new Date().getTime(); | 59 startTime = new Date().getTime(); |
59 intID = window.setInterval(calculateStats, 1000); | 60 if (statsEnabled) |
61 intID = window.setInterval(calculateStats, 1000); | |
60 }); | 62 }); |
61 | 63 |
62 video.addEventListener("error", function() { endTest(false); }, false); | 64 video.addEventListener("error", function() { endTest(false); }, false); |
63 video.addEventListener("ended", function() { endTest(true); }, false); | 65 video.addEventListener("ended", function() { endTest(true); }, false); |
64 | 66 |
65 function endTest(successFlag) { | 67 function endTest(successFlag) { |
66 window.clearInterval(intID); | 68 window.clearInterval(intID); |
67 // Notify PyAuto that we've completed the test run. | 69 // Notify PyAuto that we've completed the test run. |
68 if (window.domAutomationController) | 70 if (window.domAutomationController) |
69 window.domAutomationController.send(successFlag); | 71 window.domAutomationController.send(successFlag); |
70 } | 72 } |
71 | 73 |
72 function startTest(url) { | 74 function startTest(url, recordStats) { |
75 statsEnabled = recordStats; | |
73 // End any previously started tests. | 76 // End any previously started tests. |
74 window.clearInterval(intID); | 77 window.clearInterval(intID); |
75 | 78 |
76 video.src = url; | 79 video.src = url; |
77 video.play(); | 80 video.play(); |
78 } | 81 } |
79 </script> | 82 </script> |
80 </html> | 83 </html> |
OLD | NEW |