Sha256: 7a877bf033a5df010c619d975a448de153c65713f4c37e0e81438f2d2bf6b01e

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

#!/usr/local/bin/ruby -w

require 'benchmark'
require 'rubygems'
require 'image_science'

file = "blah_big.png"

if RUBY_PLATFORM =~ /darwin/ then
  # how fucking cool is this???
  puts "taking screenshot for thumbnailing benchmarks"
  system "screencapture -SC #{file}"
else
  abort "You need to plonk down #{file} or buy a mac"
end unless test ?f, "#{file}"

max = (ARGV.shift || 100).to_i

puts "# of iterations = #{max}"
Benchmark::bm(20) do |x|
  x.report("null_time") {
    for i in 0..max do
      # do nothing
    end
  }

  x.report("cropped") {
    for i in 0..max do
      ImageScience.with_image(file) do |img|
        img.cropped_thumbnail("blah_cropped.png", 100)
      end
    end
  }

  x.report("proportional") {
    for i in 0..max do
      ImageScience.with_image(file) do |img|
        img.thumbnail("blah_thumb.png", 100)
      end
    end
  }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
image_science-1.0.0 bench.rb