Merge branch 'bm'

* bm:
  speed and benchmark options for movie
openid
Marcin Kulik 13 years ago
commit 1b2897573e

@ -1,8 +1,7 @@
class AsciiIo.Movie
MIN_DELAY: 0.01
SPEED: 1.0
constructor: (@model) ->
constructor: (@model, @options) ->
@reset()
@startTimeReporter()
_.extend(this, Backbone.Events)
@ -46,6 +45,9 @@ class AsciiIo.Movie
@start()
start: ->
if @options.benchmark
@startTime = (new Date).getTime()
@playing = true
@lastFrameTime = (new Date()).getTime()
@nextFrame()
@ -124,7 +126,7 @@ class AsciiIo.Movie
if delay <= @MIN_DELAY
@processFrame()
else
realDelay = delay * 1000 * (1.0 / @SPEED)
realDelay = delay * 1000 * (1.0 / @options.speed)
@processFrameWithDelay(realDelay)
true
@ -132,6 +134,11 @@ class AsciiIo.Movie
@playing = false
@stopTimeReporter()
@trigger('movie-finished')
if @options.benchmark
now = (new Date).getTime()
console.log "finished in #{(now - @startTime) / 1000.0}s"
false
processFrameWithDelay: (delay) ->

@ -1,7 +1,11 @@
class AsciiIo.PlayerView extends Backbone.View
initialize: (options) ->
@movie = new AsciiIo.Movie(@model)
@movie = new AsciiIo.Movie(
@model,
speed: options.speed,
benchmark: options.benchmark
)
@movie.on 'movie-loaded', @onMovieLoaded, this
@movie.load()

@ -27,6 +27,8 @@ module AsciicastsHelper
end
def player_script(asciicast, options = {})
speed = (params[:speed] || 1).to_f
benchmark = !!params[:bm]
auto_play = options.key?(:auto_play) ? !!options[:auto_play] : false
if custom_renderer = params[:renderer]
@ -42,6 +44,8 @@ module AsciicastsHelper
el: $('.player'),
cols: #{asciicast.terminal_columns},
lines: #{asciicast.terminal_lines},
speed: #{speed},
benchmark: #{benchmark},
model: new AsciiIo.Asciicast({ id: #{asciicast.id} }),
rendererClass: #{renderer_class},
autoPlay: #{auto_play}

Loading…
Cancel
Save