Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fancier driver program

runs each benchmark 3 times and reports the fastest

tests with jpg and tiff IO
  • Loading branch information...
commit 4fc8b8addd0fcb5b426563b82cf4478007e31a9f 1 parent d772729
@jcupitt jcupitt authored
View
2  image-magick/image-magick
@@ -10,7 +10,7 @@ height=`header -f Ysize $1`
width=$((width - 200))
height=$((height - 200))
- set -x
+# set -x
convert "$1[${width}x${height}+100+100]" \
-resize 90x90% \
View
BIN  images/sample2.v
Binary file not shown
View
6 ruby/image_science.rb 100644 → 100755
@@ -3,13 +3,13 @@
require 'rubygems'
require 'image_science'
-puts "Using ImageScience #{ImageScience::VERSION}"
+# puts "Using ImageScience #{ImageScience::VERSION}"
ImageScience.with_image(ARGV[0]) do |img|
img.with_crop(100, 100, img.width() - 100, img.height() - 100) do |crop|
- puts "we are inside #with_crop"
+ # puts "we are inside #with_crop"
crop.resize(crop.width() * 0.9, crop.height() * 0.9) do |small|
- puts "we never reach inside #resize"
+ # puts "we never reach inside #resize"
small.save(ARGV[1])
end
end
View
0  ruby/rmagick.rb 100644 → 100755
File mode changed
View
0  ruby/ruby-vips.rb 100644 → 100755
File mode changed
View
70 runner
@@ -1,4 +1,70 @@
#!/bin/bash
-ruby/runner $1 $2
-image-magick/runner $1 $2
+# show the platform
+uname -a
+vips --version
+convert --version
+
+# how large an image do you want to process?
+# sample2.v is 290x442 pixels ... replicate this many times horizontally and
+# vertically to get a highres image for the benchmark
+tile=10
+
+# make a dir for our temp files
+tmp=tmp
+rm -rf $tmp
+mkdir $tmp
+
+# sample image is here
+sample=images/sample2.v
+
+echo building test image ...
+echo "tile=$tile"
+vips im_replicate $sample $tmp/t.v $tile $tile
+if [ $? != 0 ]; then
+ echo "build of test image failed -- out of disc space?"
+ exit 1
+fi
+echo -n "test image is" `header -f width $tmp/t.v`
+echo " by" `header -f height $tmp/t.v` "pixels"
+
+echo making tiff and jpeg derivatives ...
+vips copy $tmp/t.v $tmp/t.tif
+vips copy $tmp/t.v $tmp/t_tiled.tif[tile]
+vips copy $tmp/t.v $tmp/t.jpg
+
+# run three times, take the fastest real time
+function bestof3() {
+ prg=$*
+
+ t1=$(/usr/bin/time -f %e $prg 2>&1)
+ t2=$(/usr/bin/time -f %e $prg 2>&1)
+ t3=$(/usr/bin/time -f %e $prg 2>&1)
+
+ if [[ $t2 < $t1 ]]; then
+ t1=$t2
+ fi
+ if [[ $t3 < $t1 ]]; then
+ t1=$t3
+ fi
+ echo $t1
+}
+
+# run for tif and jpg sources
+function benchmark() {
+ prg=$1
+ echo -n -e "$(basename $prg)\t\t"
+ echo -n -e "$(bestof3 $prg $tmp/t.tif $tmp/t2.tif)\t\t"
+ echo -n -e "$(bestof3 $prg $tmp/t_tiled.tif $tmp/t2_tiled.tif)\t\t"
+ echo -n -e "$(bestof3 $prg $tmp/t.jpg $tmp/t2.jpg)\t\t"
+
+ echo
+}
+
+echo -e "benchmark\t\tstrip tif\ttiled tiff\tjpeg"
+benchmark ruby/ruby-vips.rb
+benchmark ruby/rmagick.rb
+benchmark image-magick/image-magick
+benchmark ruby/image_science.rb
+
+rm -rf $tmp
Please sign in to comment.
Something went wrong with that request. Please try again.