Skip to content

Instantly share code, notes, and snippets.

@atdt
Last active June 6, 2020 15:27
Show Gist options
  • Save atdt/54dc9fb673a74a6180f8b0a3ff8ee452 to your computer and use it in GitHub Desktop.
Save atdt/54dc9fb673a74a6180f8b0a3ff8ee452 to your computer and use it in GitHub Desktop.
Benchmark webp vs png for images on enwiki main page
#!/usr/bin/env bash
while IFS= read -r URL ; do
echo "$URL"
echo "WEBP:"
wrk -c1 -t1 -d5 -H 'accept: image/webp' --latency "$URL"
echo ""
echo "PNG:"
wrk -c1 -t1 -d5 --latency "$URL"
echo ""
echo ""
done < <(shuf urls.txt)
exit
curl_bench() {
FORMAT="size_download=%{size_download} bytes ; speed_download=%{speed_download} bytes/sec ; time_total=%{time_total}s speed_download=%{speed_download}s\n"
URL=https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Wikibooks-logo.svg/70px-Wikibooks-logo.svg.png
echo "webp:"
for i in {1..10} ; do
curl "$URL" --silent --header 'accept: image/webp' --compressed --write-out "$FORMAT" --output a_image
done
echo ""
echo "png:"
for i in {1..10} ; do
curl "$URL" --silent --compressed --write-out "$FORMAT" --output b_image
done
}
# wrk2 -c1 -t1 -d30 -R2 --latency "$URL"
https://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Wikiversity_logo_2017.svg/82px-Wikiversity_logo_2017.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Wikinews-logo.svg/102px-Wikinews-logo.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Wikinews-logo.svg/54px-Wikinews-logo.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/51px-Wikisource-logo.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/70px-Wikisource-logo.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikispecies-logo.svg/70px-Wikispecies-logo.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Wikibooks-logo.svg/70px-Wikibooks-logo.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Wikiquote-logo.svg/46px-Wikiquote-logo.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Wikiquote-logo.svg/70px-Wikiquote-logo.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Wikidata-logo.svg/54px-Wikidata-logo.svg.png
https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Wikidata-logo.svg/94px-Wikidata-logo.svg.png
https://upload.wikimedia.org/wikipedia/en/thumb/0/06/Wiktionary-logo-v2.svg/70px-Wiktionary-logo-v2.svg.png
https://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/40px-Commons-logo.svg.png
https://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/62px-Commons-logo.svg.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment