Skip to content

Commit

Permalink
Update benchmarks to include jpeg quality/size comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Apr 22, 2020
1 parent a5dfa3f commit a109bd6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 33 deletions.
18 changes: 11 additions & 7 deletions docker/imageflow_bench_ubuntu20/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,18 @@ RUN RUSTVER="stable" && curl https://sh.rustup.rs -sSf | sh -s -- -y --default-t
&& rustup show \
&& rustc -V

#Install hyperfine
RUN wget https://github.com/sharkdp/hyperfine/releases/download/v1.9.0/hyperfine_1.9.0_amd64.deb \
&& sudo dpkg -i hyperfine_1.9.0_amd64.deb

# Install DSSIM
RUN cargo install dssim

# Build Imageflow v1.3.0-rc30 from source with AVX2 support (haswell), then delete everything except the binary
RUN cd /home/imageflow \
&& git clone https://github.com/imazen/imageflow \
&& cd /home/imageflow/imageflow \
&& git checkout v1.3.0-rc30 \
&& git checkout v1.3.1-rc31 \
&& TARGET_CPU=haswell cargo build -p imageflow_tool_lib --release \
&& mkdir $HOME/bin \
&& cp target/release/imageflow_tool $HOME/bin/imageflow_tool \
Expand All @@ -74,15 +81,12 @@ RUN cd /home/imageflow \

WORKDIR /home/imageflow

#Install hyperfine
RUN wget https://github.com/sharkdp/hyperfine/releases/download/v1.9.0/hyperfine_1.9.0_amd64.deb \
&& sudo dpkg -i hyperfine_1.9.0_amd64.deb


RUN wget -nc --quiet https://s3-us-west-2.amazonaws.com/imageflow-resources/test_inputs/u1.jpg
ADD bench.sh .
RUN sudo chmod +x $HOME/bench.sh

ENTRYPOINT ./bench.sh
CMD ["thumbnail"]

ENTRYPOINT ["./bench.sh"]

MAINTAINER Lilith River
81 changes: 55 additions & 26 deletions docker/imageflow_bench_ubuntu20/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

echo 'This benchmark is for ubuntu 20.04. '

$HOME/bin/imageflow_tool --version
"$HOME/bin/imageflow_tool" --version
convert --version
vipsthumbnail --vips-version

Expand All @@ -15,30 +15,59 @@ rm bench_in/*.jpg

export COUNT=32

for i in $(seq 1 $COUNT);
do
cp "u1.jpg" "bench_in/c$i.jpg"
for i in $(seq 1 $COUNT); do
cp "u1.jpg" "bench_in/c$i.jpg"
done

(
cd bench_in || exit
hyperfine --export-markdown results.md --warmup 1 \
'parallel "$HOME/bin/imageflow_tool v0.1/ir4 --in {} --out ../bench_out/{.}_200x200.jpg --command width=200&height=200&mode=max&quality=90" ::: *.jpg' \
'parallel "vipsthumbnail --linear --size=200x200 --output=../bench_out/{.}_vips_200x200.jpg[Q=90] {}" ::: *.jpg' \
'parallel "convert {} -set colorspace sRGB -colorspace RGB -filter Robidoux -resize 200x200 -colorspace sRGB -quality 90 ../bench_out/{.}_magick_200x200.jpg" ::: *.jpg' \
'parallel "convert {} -set colorspace sRGB -colorspace RGB -filter Mitchell -distort Resize 200x200 -colorspace sRGB -quality 90 ../bench_out/{.}_magick_ideal_200x200.jpg" ::: *.jpg'

echo "=============== Results in Markdown format ======================"
cat results.md
echo "================================================================="

hyperfine --export-markdown results.md --warmup 1 \
'parallel "$HOME/bin/imageflow_tool v0.1/ir4 --in {} --out ../bench_out/{.}_2000x2000.jpg --command width=2000&height=2000&mode=max&quality=90" ::: *.jpg' \
'parallel "vipsthumbnail --linear --size=2000x2000 --output=../bench_out/{.}_vips_2000x2000.jpg[Q=90] {}" ::: *.jpg' \
'parallel "convert {} -set colorspace sRGB -colorspace RGB -filter Robidoux -resize 2000x2000 -colorspace sRGB -quality 90 ../bench_out/{.}_magick_2000x2000.jpg" ::: *.jpg' \
'parallel "convert {} -set colorspace sRGB -colorspace RGB -filter Mitchell -distort Resize 2000x2000 -colorspace sRGB -quality 90 ../bench_out/{.}_magick_ideal_2000x2000.jpg" ::: *.jpg'

echo "=============== Results in Markdown format ======================"
cat results.md
echo "================================================================="
)
cd bench_in

if [[ "$1" == "thumbnail" ]]; then
hyperfine --export-markdown results.md --warmup 3 \
'parallel "$HOME/bin/imageflow_tool v0.1/ir4 --in {} --out ../bench_out/{.}_200x200.jpg --command width=\"200&height=200&mode=max&quality=9\"" ::: *.jpg' \
'parallel "vipsthumbnail --linear --size=200x200 --output=../bench_out/{.}_vips_200x200.jpg[Q=90] {}" ::: *.jpg' \
'parallel "convert {} -set colorspace sRGB -colorspace RGB -filter Robidoux -resize 200x200 -colorspace sRGB -quality 90 ../bench_out/{.}_magick_200x200.jpg" ::: *.jpg'

echo "=============== Results in Markdown format ======================"
cat results.md
echo "================================================================="
fi
if [[ "$1" == "downscale" ]]; then
cd bench_in || exit
hyperfine --export-markdown results.md --warmup 3 \
'parallel "$HOME/bin/imageflow_tool v0.1/ir4 --in {} --out ../bench_out/{.}_2000x2000.jpg --command width=\"2000&height=2000&mode=max&quality=90\"" ::: *.jpg' \
'parallel "vipsthumbnail --linear --size=2000x2000 --output=../bench_out/{.}_vips_2000x2000.jpg[Q=90] {}" ::: *.jpg' \
'parallel "convert {} -set colorspace sRGB -colorspace RGB -filter Robidoux -resize 2000x2000 -colorspace sRGB -quality 90 ../bench_out/{.}_magick_2000x2000.jpg" ::: *.jpg'

echo "=============== Results in Markdown format ======================"
cat results.md
echo "================================================================="
fi

if [[ "$1" == "jpegsize" ]]; then

"$HOME/bin/imageflow_tool" v0.1/ir4 --in c1.jpg --out ../bench_out/imageflow_2000x2000.jpg --command "width=2000&height=2000&mode=max&quality=89" 1>/dev/null
vipsthumbnail --linear --size=2000x2000 --output=../bench_out/vips_2000x2000.jpg[Q=89,strip,optimize-coding] c1.jpg

"$HOME/bin/imageflow_tool" v0.1/ir4 --in c1.jpg --out ../bench_out/imageflow_reference_2000x2000.png --command "width=2000&height=2000&mode=max&format=png&decoder.min_precise_scaling_ratio=100" 1>/dev/null
vipsthumbnail --linear --size=2000x2000 --output=../bench_out/vips_reference_2000x2000.png c1.jpg

"$HOME/bin/imageflow_tool" v0.1/ir4 --in ../bench_out/imageflow_2000x2000.jpg --out ../bench_out/imageflow_2000x2000.png --command "format=png" 1>/dev/null
"$HOME/bin/imageflow_tool" v0.1/ir4 --in ../bench_out/vips_2000x2000.jpg --out ../bench_out/vips_2000x2000.png --command "format=png" 1>/dev/null

echo "=============== DSSIM relative to imageflow reference (lower is better) ======================"
dssim ../bench_out/imageflow_reference_2000x2000.png ../bench_out/imageflow_2000x2000.png
dssim ../bench_out/imageflow_reference_2000x2000.png ../bench_out/vips_2000x2000.png

echo "=============== DSSIM relative to libvips reference (lower is better) ======================"
dssim ../bench_out/imageflow_reference_2000x2000.png ../bench_out/imageflow_2000x2000.png
dssim ../bench_out/vips_reference_2000x2000.png ../bench_out/vips_2000x2000.png

echo "=============== File sizes ======================"
ls -l ../bench_out
echo "================================================================="
# shellcheck disable=SC2028
echo "To see results, run docker run -v %CD%\results:/home/imageflow/bench_out imazen/imageflow_bench_ubuntu20 jpegsize"
echo 'or on linux, docker run -v \"$(pwd)\"/results:/home/imageflow/bench_out imazen/imageflow_bench_ubuntu20 jpegsize'

fi

2 comments on commit a109bd6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New misspellings found, please review:

  • esults
  • jpegsize
To accept these changes, run the following commands
remove_obsolete_words=$(mktemp)
echo '#!/usr/bin/perl -ni
my $re=join "|", qw('"
jsoref
megapixels
"');
next if /^($re)(?:$| .*)/;
print;' > $remove_obsolete_words
chmod +x $remove_obsolete_words
for file in .github/actions/spell-check/whitelist/42f15d0ed3748dd6a1b8c1f026d297f0625fb5eb.txt .github/actions/spell-check/whitelist/whitelist.txt; do $remove_obsolete_words $file; done
rm $remove_obsolete_words
(
echo "
esults
jpegsize
"
) | sort -u -f | perl -ne 'next unless /./; print' > new_whitelist.txt && mv new_whitelist.txt '.github/actions/spell-check/whitelist/a109bd62e2490540ac0f35c0b904bd1ae2fa198f.txt'

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New misspellings found, please review:

  • esults
  • jpegsize
To accept these changes, run the following commands
remove_obsolete_words=$(mktemp)
echo '#!/usr/bin/perl -ni
my $re=join "|", qw('"
jsoref
megapixels
"');
next if /^($re)(?:$| .*)/;
print;' > $remove_obsolete_words
chmod +x $remove_obsolete_words
for file in .github/actions/spell-check/whitelist/42f15d0ed3748dd6a1b8c1f026d297f0625fb5eb.txt .github/actions/spell-check/whitelist/whitelist.txt; do $remove_obsolete_words $file; done
rm $remove_obsolete_words
(
echo "
esults
jpegsize
"
) | sort -u -f | perl -ne 'next unless /./; print' > new_whitelist.txt && mv new_whitelist.txt '.github/actions/spell-check/whitelist/a109bd62e2490540ac0f35c0b904bd1ae2fa198f.txt'

Please sign in to comment.