Skip to content

Instantly share code, notes, and snippets.

@joyrexus
Created June 27, 2013 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joyrexus/5879519 to your computer and use it in GitHub Desktop.
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)
#!/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