Created
July 8, 2015 06:40
-
-
Save koshigoe/158b0d70353c93cf1214 to your computer and use it in GitHub Desktop.
画像100%リサイズを mini_magick と convert で比較
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
| require 'benchmark' | |
| require 'mini_magick' | |
| require 'open3' | |
| n = 100 | |
| Benchmark.bm(22) do |x| | |
| x.report("mini_magic") do | |
| n.times do | |
| blob = File.open('sample.jpg') | |
| image = MiniMagick::Image.read(blob) | |
| image.resize "100%" | |
| end | |
| end | |
| x.report("convert") do | |
| n.times do | |
| Open3.popen3('convert -resize 100% sample.jpg -') do |stdin, stdout, stderr, wait_thr| | |
| stdin.close | |
| output = stdout.read | |
| end | |
| end | |
| end | |
| end |
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
| $ ruby bench-image-resize.rb | |
| user system total real | |
| mini_magic 0.090000 0.190000 2.300000 ( 3.258090) | |
| convert 0.040000 0.090000 1.560000 ( 1.922639) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment