Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7674b4b951
Fetching contributors…

Cannot retrieve contributors at this time

executable file 124 lines (100 sloc) 2.408 kb
#!/bin/bash
# show the platform
uname -a
./ruby/versions/ruby-vips.rb
convert --version
tifftopnm --version
./ruby/versions/image_science.rb
# 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 im_copy $tmp/t.v $tmp/t.tif
vips im_copy $tmp/t.v $tmp/t.jpg
# we want to use the time program, not the one built into the shell
time=$(which time)
if [ $? != 0 ]; then
echo "unable to locate 'time' program"
exit 1
fi
# run three times, take the fastest real time
function bestof3() {
prg=$*
t1=$($time -f %e $prg 2>&1)
t2=$($time -f %e $prg 2>&1)
t3=$($time -f %e $prg 2>&1)
if [[ $t2 < $t1 ]]; then
t1=$t2
fi
if [[ $t3 < $t1 ]]; then
t1=$t3
fi
echo $t1
}
# find peak RSS
function maxmem() {
prg=$*
m=$($time -f %M $prg 2>&1)
echo -n -e "$(basename $1)\t"
echo $m
}
# run for tif and jpg sources
function benchmark() {
prg=$1
echo -n -e "$(basename $prg)\t"
echo -n -e "$(bestof3 $prg $tmp/t.tif $tmp/t2.tif)\t"
echo -n -e "$(bestof3 $prg $tmp/t.jpg $tmp/t2.jpg)\t"
echo
}
# tests we run
programs="\
ruby/ruby-vips.rb \
ruby/rmagick.rb \
image-magick/image-magick \
ruby/image_sci.rb \
netpbm/netpbm.sh \
"
rm -f $tmp/log
for prg in $programs; do
echo -n timing $prg ...
benchmark $prg >> $tmp/log
echo " done"
done
# we can't test all of them for max memory, only ones which don't fork
# subprocesses
programs="\
ruby/ruby-vips.rb \
ruby/rmagick.rb \
ruby/image_sci.rb \
"
rm -f $tmp/memlog
for prg in $programs; do
echo -n measuring memuse for $prg ...
maxmem $prg $tmp/t.tif $tmp/t2.tif >> $tmp/memlog
echo " done"
done
echo
echo real time in seconds, fastest of three runs
echo -e "benchmark\ttiff\tjpeg"
sort -g -k 2 $tmp/log
echo
echo peak memory use in kilobytes
echo -e "benchmark\tpeak RSS"
sort -g -k 2 $tmp/memlog
rm -rf $tmp
Jump to Line
Something went wrong with that request. Please try again.