fix(archive): handle invalid UTF-8 passwords in 7z decompression
[ouch.git] / benchmarks / run-benchmarks.sh
blob225a60ec7261e7887fb91a2a67d71fbdd235431e
1 #!/usr/bin/env bash
3 # Input files used:
4 # - `compiler` (27 MB) for compressed formats.
5 # - `rust` (229 MB) for uncompressed formats.
7 # Compressed formats benchmarked:
8 # - .tar.gz
9 # - .zip
11 # Uncompressed formats benchmarked:
12 # - .tar
14 set -e
16 DESCOMPRESSION_CLEANUP="rm output -r"
18 function call_hyperfine() {
19 hyperfine "$@" \
20 --warmup 4 \
21 --export-markdown "${FUNCNAME[1]}.md"
24 function tar_compression() {
25 cleanup="rm output.tar"
27 call_hyperfine \
28 'ouch compress rust output.tar' \
29 'tar -cvf output.tar rust' \
30 --prepare "$cleanup || true"
32 $cleanup
35 function tar_decompression() {
36 echo "Creating tar archive to benchmark decompression..."
37 ouch compress rust input.tar --yes &> /dev/null
39 call_hyperfine \
40 'ouch decompress input.tar --dir output' \
41 'tar -xv -C output -f input.tar' \
42 --prepare "$DESCOMPRESSION_CLEANUP || true" \
43 --prepare "$DESCOMPRESSION_CLEANUP || true ; mkdir output"
45 $DESCOMPRESSION_CLEANUP
48 function tar_gz_compression() {
49 cleanup="rm output.tar.gz"
51 call_hyperfine \
52 'ouch compress compiler output.tar.gz' \
53 'tar -cvzf output.tar.gz compiler' \
54 --prepare "$cleanup || true"
56 $cleanup
59 function tar_gz_decompression() {
60 echo "Creating tar.gz archive to benchmark decompression..."
61 ouch compress compiler input.tar.gz --yes &> /dev/null
63 call_hyperfine \
64 'ouch decompress input.tar.gz --dir output' \
65 'tar -xvz -C output -f input.tar.gz' \
66 --prepare "$DESCOMPRESSION_CLEANUP || true" \
67 --prepare "$DESCOMPRESSION_CLEANUP || true ; mkdir output"
69 $DESCOMPRESSION_CLEANUP
72 function zip_compression() {
73 cleanup="rm output.zip"
75 call_hyperfine \
76 'zip output.zip -r compiler' \
77 'ouch compress compiler output.zip' \
78 --prepare "$cleanup || true"
80 $cleanup
83 function zip_decompression() {
84 echo "Creating zip archive to benchmark decompression..."
85 ouch compress compiler input.zip --yes &> /dev/null
87 call_hyperfine \
88 'ouch decompress input.zip --dir output' \
89 'unzip input.zip -d output' \
90 --prepare "$DESCOMPRESSION_CLEANUP || true"
92 $DESCOMPRESSION_CLEANUP
95 function run_benches() {
96 tar_compression
97 tar_decompression
98 tar_gz_compression
99 tar_gz_decompression
100 zip_compression
101 zip_decompression
104 function concatenate_results() {
105 cat tar_compression.md <(echo) \
106 tar_decompression.md <(echo) \
107 tar_gz_compression.md <(echo) \
108 tar_gz_decompression.md <(echo) \
109 zip_compression.md <(echo) \
110 zip_decompression.md > results.md
113 run_benches
114 concatenate_results
116 echo
117 echo "check results at results.md"