Skip to content

Instantly share code, notes, and snippets.

@janko janko/results
Last active Aug 24, 2019

Embed
What would you like to do?
MiniMagick vs libvips benchmark (generating a 500x500 thumbnail)
width, imagemagick, libvips
1000, 0.129, 0.045
1500, 0.190, 0.067
2000, 0.276, 0.054
2500, 0.380, 0.068
3000, 0.498, 0.085
require "bundler/inline"
gemfile do
gem "image_processing"
gem "down"
gem "benchmark-ips"
end
require "image_processing/mini_magick" # imagemagick 7.0.8-59
require "image_processing/vips" # vips 8.8.1
require "down"
require "benchmark/ips"
require "csv"
# disable cache
Vips.vips_cache_set_max 0
csv = CSV.new(STDOUT)
csv << ["width", "imagemagick", "libvips"]
1000.step(by: 500, to: 3000) do |source_width|
source = Down.download("https://images.unsplash.com/photo-1549221838-126dc3ebf29f?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&w=#{source_width}")
result = Benchmark.ips(quiet: true) do |x|
x.report("imagemagick (#{source_width}px)") do
ImageProcessing::MiniMagick
.source(source)
.resize_to_limit!(500, 500)
end
x.report("libvips (#{source_width}px)") do
ImageProcessing::Vips
.source(source)
.resize_to_limit!(500, 500)
end
end
imagemagick_duration = 1 / result.data.first.fetch(:ips)
libvips_duration = 1 / result.data.last.fetch(:ips)
csv << [source_width, "%.3f" % imagemagick_duration, "%.3f" % libvips_duration]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.