Created
November 6, 2014 02:39
-
-
Save benkaiser/fd3d5d4e664a219ae447 to your computer and use it in GitHub Desktop.
frame_counter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // constants | |
| var MISSED_FRAMES = 10; | |
| // application | |
| var readline = require('readline'); | |
| var rl = readline.createInterface({ | |
| input: process.stdin, | |
| output: process.stdout | |
| }); | |
| var timestamps = []; | |
| rl.on('line', function(line){ | |
| if(line){ | |
| // it exists, add it on | |
| var words = line.split(" "); | |
| timestamps.push(+words[words.length - 1]); | |
| } else { | |
| // calculte | |
| var duration = timestamps[timestamps.length - 1] - timestamps[0]; | |
| var frame_length = duration / timestamps.length; | |
| var frame_rate = 1000 / frame_length; | |
| console.log(frame_rate * MISSED_FRAMES); | |
| // reset | |
| timestamps = []; | |
| } | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was a quick script I chucked together to count the number of frames per second in an android app I was developing. It's static and doesn't show on the device, so it is of very limited usefulness, but it solved the task I wanted of getting rough estimates of the frames per second.
To use, simply run the app, paste in the adb input, with the timestamps as the last element, then press enter twice to see the calculated frames per second.
Here is some example usage:
Customize the
MISSED_FRAMESvariables to skip frames (so that the sending to adb doesn't effect the performance too much. For my example, I was using 10 like so: