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