Sha256: d01c965b94b6a1536b98e7681078ecb106464be4784213d388a848d64fa55aa2
Contents?: true
Size: 1.31 KB
Versions: 33
Compression:
Stored size: 1.31 KB
Contents
#!/usr/local/bin/ruby -w require 'benchmark' require 'rubygems' require 'image_science' max = (ARGV.shift || 100).to_i ext = ARGV.shift || "png" file = "blah_big.#{ext}" 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}" ImageScience.with_image(file.sub(/#{ext}$/, 'png')) do |img| img.save(file) end if ext != "png" 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(100) do |thumb| thumb.save("blah_cropped.#{ext}") end end end } x.report("proportional") { for i in 0..max do ImageScience.with_image(file) do |img| img.thumbnail(100) do |thumb| thumb.save("blah_thumb.#{ext}") end end end } x.report("resize") { for i in 0..max do ImageScience.with_image(file) do |img| img.resize(200, 200) do |resize| resize.save("blah_resize.#{ext}") end end end } end # File.unlink(*Dir["blah*#{ext}"])
Version data entries
33 entries across 33 versions & 9 rubygems