Created
June 27, 2013 19:19
-
-
Save joyrexus/5879519 to your computer and use it in GitHub Desktop.
Show the time-related info for a leap gesture sample (frames, secs, FPS)
This file contains 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
#!/usr/bin/env coffee | |
# | |
# Show the time-related info for a leap gesture sample: | |
# | |
# frames - number of frames | |
# seconds - number of seconds | |
# FPS - frames per second | |
# | |
# Usage: | |
# | |
# timing.coffee sample.json | |
# | |
fs = require 'fs' | |
print = console.log | |
calc = (data) -> | |
frames = JSON.parse(data) | |
last = frames.length - 1 | |
start = frames[0].timestamp | |
stop = frames[last].timestamp | |
secs = (stop - start) / 1000000 | |
info = | |
frames: frames.length | |
seconds: secs | |
FPS: frames.length / secs | |
show = (err, data) -> | |
if err | |
print err | |
else | |
print calc data | |
info = (file) -> fs.readFile file, 'utf8', show | |
file = process.argv.pop() | |
info file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment