Sha256: 2d879431b6739a40b8dada5091cff1b75234b01e120fce24bdc11de0b3ea4f40

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'ws_light/animation/fade_animation'
require 'ws_light/animation/slide_left_animation'
require 'ws_light/animation/slide_right_animation'
require 'ws_light/set/color_set'

require 'benchmark'
include Benchmark


color_set_from = WSLight::Set::ColorSet.new
color_set_from.color = WSLight::Color.new(255, 127, 0)
color_set_to = WSLight::Set::ColorSet.new
color_set_to.color = WSLight::Color.new(0, 127, 255)

@fade_animation = WSLight::Animation::FadeAnimation.new(color_set_from, color_set_to)
@slide_left_animation = WSLight::Animation::SlideLeftAnimation.new(color_set_from, color_set_to)
@slide_right_animation = WSLight::Animation::SlideRightAnimation.new(color_set_from, color_set_to)

n = 10_000

puts "Testing #{n} animation cycles with a simple color set..."

Benchmark.bm(15) do |x|
  x.report('FadeAnimation:') { n.times do @fade_animation.frame(n%50) end }
  x.report('SlideLeftAnimation:') { n.times do @slide_left_animation.frame(n%50) end }
  x.report('SlideRightAnimation:') { n.times do @slide_right_animation.frame(n%50) end }
end

puts "To run smoothly, the benchmarks should all be lower than #{n/50.0} seconds."

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ws_light-0.4.2 lib/ws_light/benchmark/animation_benchmark.rb
ws_light-0.3.0 lib/ws_light/benchmark/animation_benchmark.rb
ws_light-0.2.0 lib/ws_light/benchmark/animation_benchmark.rb