Sha256: 8177f5fddace7a9a1b8ad1b078baa69e3afe5567c9a2a3deb7027713c0e2362c

Contents?: true

Size: 1.33 KB

Versions: 38

Compression:

Stored size: 1.33 KB

Contents

require 'rubygems'
require 'bundler/setup'

require 'benchmark'
require 'chunky_png'

def image_file(name)
  File.join(File.dirname(__FILE__), '..', 'spec', 'resources', name)
end

def image_data(name)
  data = nil
  File.open(image_file(name), 'rb') { |f| data = f.read }
  data
end

no_filtering_stream    = image_data('pixelstream_fast_rgba.png')
up_filtering_stream    = image_data('pixelstream_reference.png')
paeth_filtering_stream = image_data('pixelstream_best_compression.png')
rgba_pixelstream       = image_data('pixelstream.rgba')
rgb_pixelstream        = image_data('pixelstream.rgb')

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

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

Benchmark.bmbm do |x|
  x.report('PNG - no filtering')    { n.times { ChunkyPNG::Image.from_blob(no_filtering_stream) } }
  x.report('PNG - UP filtering')    { n.times { ChunkyPNG::Image.from_blob(up_filtering_stream) } }
  x.report('PNG - PAETH filtering') { n.times { ChunkyPNG::Image.from_blob(paeth_filtering_stream) } }
  x.report('From RGBA pixelstream') { n.times { ChunkyPNG::Image.from_rgba_stream(240, 180, rgba_pixelstream) } }
  x.report('From RGB pixelstream')  { n.times { ChunkyPNG::Image.from_rgb_stream(240, 180, rgb_pixelstream) } }
end

Version data entries

38 entries across 36 versions & 6 rubygems

Version Path
chunky_png-1.3.11 benchmarks/decoding_benchmark.rb
chunky_png-1.3.10 benchmarks/decoding_benchmark.rb
chunky_png-1.3.9 benchmarks/decoding_benchmark.rb
arcabouco-0.2.13 vendor/bundle/gems/chunky_png-1.3.8/benchmarks/decoding_benchmark.rb
arcabouco-0.2.13 vendor/bundle/gems/chunky_png-1.3.6/benchmarks/decoding_benchmark.rb
chunky_png-1.3.8 benchmarks/decoding_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/decoding_benchmark.rb
chunky_png-1.3.7 benchmarks/decoding_benchmark.rb
chunky_png-1.3.6 benchmarks/decoding_benchmark.rb
bench9000-0.1 vendor/chunky_png/benchmarks/decoding_benchmark.rb
chunky_png-1.3.5 benchmarks/decoding_benchmark.rb
chunky_png-1.3.4 benchmarks/decoding_benchmark.rb
chunky_png-1.3.3 benchmarks/decoding_benchmark.rb
chunky_png-1.3.2 benchmarks/decoding_benchmark.rb
chunky_png-1.3.1 benchmarks/decoding_benchmark.rb
sadui-0.0.4 vendor/bundle/ruby/2.0.0/gems/chunky_png-1.3.0/benchmarks/decoding_benchmark.rb
sadui-0.0.4 vendor/bundle/ruby/2.1.0/gems/chunky_png-1.3.0/benchmarks/decoding_benchmark.rb
chunky_png-1.3.0 benchmarks/decoding_benchmark.rb
chunky_png-1.2.9 benchmarks/decoding_benchmark.rb
chunky_png-1.2.8 benchmarks/decoding_benchmark.rb