Sha256: 0368d3174f2a2dac627acb9cf16051bab9efdb36626bfda6a44ee309a5e11766

Contents?: true

Size: 1.58 KB

Versions: 38

Compression:

Stored size: 1.58 KB

Contents

require 'rubygems'
require 'bundler/setup'

require 'benchmark'
require 'chunky_png'

image = ChunkyPNG::Image.new(240, 180, ChunkyPNG::Color::TRANSPARENT)

# set some random pixels
image[10, 20] = ChunkyPNG::Color.rgba(255,   0,   0, 255)
image[50, 87] = ChunkyPNG::Color.rgba(  0, 255,   0, 255)
image[33, 99] = ChunkyPNG::Color.rgba(  0,   0, 255, 255)

n = (ENV['N'] || '5').to_i

puts "---------------------------------------------"
puts "ChunkyPNG (#{ChunkyPNG::VERSION}) encoding benchmark (n=#{n})"
puts "---------------------------------------------"
puts

Benchmark.bmbm do |x|
  x.report('Autodetect (indexed)')  { n.times { image.to_blob } }

  # Presets
  x.report(':no_compression')    { n.times { image.to_blob(:no_compression) } }
  x.report(':fast_rgba')         { n.times { image.to_blob(:fast_rgba) } }
  x.report(':fast_rgb')          { n.times { image.to_blob(:fast_rgb) } }
  x.report(':good_compression')  { n.times { image.to_blob(:good_compression) } }
  x.report(':best_compression')  { n.times { image.to_blob(:best_compression) } }
  
  # Some options
  x.report(':rgb')        { n.times { image.to_blob(:color_mode => ChunkyPNG::COLOR_TRUECOLOR) } }
  x.report(':rgba')       { n.times { image.to_blob(:color_mode => ChunkyPNG::COLOR_TRUECOLOR_ALPHA) } }
  x.report(':indexed')    { n.times { image.to_blob(:color_mode => ChunkyPNG::COLOR_INDEXED) } }
  x.report(':interlaced') { n.times { image.to_blob(:interlaced => true) } }
  
  # Exports
  x.report('to RGBA pixelstream') { n.times { image.to_rgba_stream } }
  x.report('to RGB pixelstream')  { n.times { image.to_rgb_stream } }
end

Version data entries

38 entries across 36 versions & 6 rubygems

Version Path
chunky_png-1.3.11 benchmarks/encoding_benchmark.rb
chunky_png-1.3.10 benchmarks/encoding_benchmark.rb
chunky_png-1.3.9 benchmarks/encoding_benchmark.rb
arcabouco-0.2.13 vendor/bundle/gems/chunky_png-1.3.8/benchmarks/encoding_benchmark.rb
arcabouco-0.2.13 vendor/bundle/gems/chunky_png-1.3.6/benchmarks/encoding_benchmark.rb
chunky_png-1.3.8 benchmarks/encoding_benchmark.rb
second_step-0.1.2 secondstep-notify-1.0.0-osx/lib/ruby/lib/ruby/gems/2.2.0/gems/chunky_png-1.3.7/benchmarks/encoding_benchmark.rb
chunky_png-1.3.7 benchmarks/encoding_benchmark.rb
chunky_png-1.3.6 benchmarks/encoding_benchmark.rb
bench9000-0.1 vendor/chunky_png/benchmarks/encoding_benchmark.rb
chunky_png-1.3.5 benchmarks/encoding_benchmark.rb
chunky_png-1.3.4 benchmarks/encoding_benchmark.rb
chunky_png-1.3.3 benchmarks/encoding_benchmark.rb
chunky_png-1.3.2 benchmarks/encoding_benchmark.rb
chunky_png-1.3.1 benchmarks/encoding_benchmark.rb
sadui-0.0.4 vendor/bundle/ruby/2.0.0/gems/chunky_png-1.3.0/benchmarks/encoding_benchmark.rb
sadui-0.0.4 vendor/bundle/ruby/2.1.0/gems/chunky_png-1.3.0/benchmarks/encoding_benchmark.rb
chunky_png-1.3.0 benchmarks/encoding_benchmark.rb
chunky_png-1.2.9 benchmarks/encoding_benchmark.rb
chunky_png-1.2.8 benchmarks/encoding_benchmark.rb