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, Memory, and FPS Perf Test</title> |
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; | |
20 var droppedFrames = 0; | |
21 var decodedFPS = []; | |
22 var droppedFPS = []; | |
23 var startTime = 0; | |
24 var intID = 0; // interval ID, used to end the window intervals. | |
25 | |
26 function calculateStats() { | 19 function calculateStats() { |
27 if (video.readyState <= HTMLMediaElement.HAVE_CURRENT_DATA || | 20 if (video.readyState <= HTMLMediaElement.HAVE_CURRENT_DATA || |
28 video.paused || video.ended) | 21 video.paused || video.ended) |
29 return; | 22 return; |
30 | 23 |
31 currentTime = new Date().getTime(); | 24 currentTime = new Date().getTime(); |
32 deltaTime = (currentTime - startTime) / 1000; | 25 deltaTime = (currentTime - startTime) / 1000; |
33 startTime = currentTime; | 26 startTime = currentTime; |
34 | 27 |
35 // Calculate decoded frames per sec. | 28 // Calculate decoded frames per sec. |
(...skipping 27 matching lines...) Expand all Loading... |
63 video.addEventListener("ended", function() { endTest(true); }, false); | 56 video.addEventListener("ended", function() { endTest(true); }, false); |
64 | 57 |
65 function endTest(successFlag) { | 58 function endTest(successFlag) { |
66 window.clearInterval(intID); | 59 window.clearInterval(intID); |
67 // Notify PyAuto that we've completed the test run. | 60 // Notify PyAuto that we've completed the test run. |
68 if (window.domAutomationController) | 61 if (window.domAutomationController) |
69 window.domAutomationController.send(successFlag); | 62 window.domAutomationController.send(successFlag); |
70 } | 63 } |
71 | 64 |
72 function startTest(url) { | 65 function startTest(url) { |
73 // End any previously started tests. | |
74 window.clearInterval(intID); | |
75 | |
76 video.src = url; | 66 video.src = url; |
77 video.play(); | 67 video.play(); |
78 } | 68 } |
79 </script> | 69 </script> |
80 </html> | 70 </html> |
OLD | NEW |