Created
July 24, 2012 00:19
-
-
Save cespare/3167123 to your computer and use it in GitHub Desktop.
Imagemagick (rmagick) benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Need to install imagemagick first. | |
# sudo apt-get install libmagickwand on ubuntu. | |
# Available on homebrew as well. | |
require "RMagick" | |
images = Dir["./*.png"] | |
start_time = Time.now | |
iterations = 0 | |
100.times do | |
# Load the image into rmagick | |
images.each do |path| | |
iterations += 1 | |
image = Magick::Image.read(path).first | |
image.resize_to_fill!(66, 35) | |
# Ruby GC doesn't necessarily interact well with big binary blogs. Destroy explicitly. | |
image.destroy! | |
end | |
end | |
elapsed = Time.now - start_time | |
puts "Avg. #{(elapsed.to_f * 1000.0 / iterations).round(2)} ms / conversion" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment