Sha256: 0d8e7c3ac43ef52ccb72f6c32b7f7776f32bad6c4c1e0234c13334d5d79bc7a6

Contents?: true

Size: 1.09 KB

Versions: 29

Compression:

Stored size: 1.09 KB

Contents

require 'rubygems'
require 'bundler/setup'

require 'benchmark'
require 'chunky_png'

files = ['pixelstream_reference.png', 'operations.png', 'clock_stubbed.png']

def encode_png(image, constraints = {})
  filesize = nil
  time = Benchmark.realtime { filesize = image.to_blob(constraints).bytesize }
  [filesize, time]
end

files.each do |file|
  filename = File.join(File.dirname(__FILE__), '..', 'spec', 'resources', file)
  image = ChunkyPNG::Canvas.from_file(filename)

  puts "#{file}: #{image.width}x#{image.height} - #{image.palette.size} colors"
  puts "------------------------------------------------"
  puts "<default>         : %8d bytes in %0.4fs" % encode_png(image)
  puts ":no_compression   : %8d bytes in %0.4fs" % encode_png(image, :no_compression)
  puts ":fast_rgba        : %8d bytes in %0.4fs" % encode_png(image, :fast_rgba)
  puts ":fast_rgb         : %8d bytes in %0.4fs" % encode_png(image, :fast_rgb)
  puts ":good_compression : %8d bytes in %0.4fs" % encode_png(image, :good_compression)
  puts ":best_compression : %8d bytes in %0.4fs" % encode_png(image, :best_compression)
  puts
end

Version data entries

29 entries across 28 versions & 4 rubygems

Version Path
bench9000-0.1 vendor/chunky_png/benchmarks/filesize_benchmark.rb
chunky_png-1.3.5 benchmarks/filesize_benchmark.rb
chunky_png-1.3.4 benchmarks/filesize_benchmark.rb
chunky_png-1.3.3 benchmarks/filesize_benchmark.rb
chunky_png-1.3.2 benchmarks/filesize_benchmark.rb
chunky_png-1.3.1 benchmarks/filesize_benchmark.rb
sadui-0.0.4 vendor/bundle/ruby/2.0.0/gems/chunky_png-1.3.0/benchmarks/filesize_benchmark.rb
sadui-0.0.4 vendor/bundle/ruby/2.1.0/gems/chunky_png-1.3.0/benchmarks/filesize_benchmark.rb
chunky_png-1.3.0 benchmarks/filesize_benchmark.rb
chunky_png-1.2.9 benchmarks/filesize_benchmark.rb
chunky_png-1.2.8 benchmarks/filesize_benchmark.rb
chunky_png-1.2.7 benchmarks/filesize_benchmark.rb
chunky_png-1.2.6 benchmarks/filesize_benchmark.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/chunky_png-1.2.5/benchmarks/filesize_benchmark.rb
chunky_png-1.2.5 benchmarks/filesize_benchmark.rb
chunky_png-1.2.4 benchmarks/filesize_benchmark.rb
chunky_png-1.2.3 benchmarks/filesize_benchmark.rb
chunky_png-1.2.2 benchmarks/filesize_benchmark.rb
chunky_png-1.2.1 benchmarks/filesize_benchmark.rb
chunky_png-1.2.0 benchmarks/filesize_benchmark.rb