Skip to content

update benchmark

update benchmark #31

name: Enwik8 Benchmark
on:
workflow_dispatch:
push:
jobs:
enwik8-benchmark:
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
rustflags: --allow warnings -C target-feature=+aes
- name: Build
run: cargo build --release
- name: Install zstd
run: sudo apt-get -y update && sudo apt-get -y install zstd
- name: Install brotli
run: sudo apt-get -y update && sudo apt-get -y install brotli
- name: Preparing enwik8
run: xz -d < test/enwik8.xz >enwik8
- name: Benchmark with with enwik8
run: |
(time gzip -9 < enwik8 >enwik8.gz) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >gzip.enc_time
(time gzip -d < enwik8.gz >enwik8.ungz) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >gzip.dec_time
(time bzip2 -9 < enwik8 >enwik8.bz2) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >bzip2.enc_time
(time bzip2 -d < enwik8.bz2 >enwik8.unbz2) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >bzip2.dec_time
(time zstd -10 < enwik8 >enwik8.zstd10) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >zstd10.enc_time
(time zstd -d < enwik8.zstd10 >enwik8.unzstd10) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >zstd10.dec_time
(time zstd -15 < enwik8 >enwik8.zstd15) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >zstd15.enc_time
(time zstd -d < enwik8.zstd15 >enwik8.unzstd15) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >zstd15.dec_time
(time zstd -19 < enwik8 >enwik8.zstd19) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >zstd19.enc_time
(time zstd -d < enwik8.zstd19 >enwik8.unzstd19) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >zstd19.dec_time
(time brotli -6 < enwik8 >enwik8.br6) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >br6.enc_time
(time brotli -d < enwik8.br6 >enwik8.unbr6) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >br6.dec_time
(time brotli -9 < enwik8 >enwik8.br9) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >br9.enc_time
(time brotli -d < enwik8.br9 >enwik8.unbr9) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >br9.dec_time
(time xz -6 < enwik8 >enwik8.xz) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >xz.enc_time
(time xz -d < enwik8.xz >enwik8.unxz) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >xz.dec_time
(time target/release/orz encode --silent -l0 < enwik8 >enwik8.orz0) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz0.enc_time
(time target/release/orz decode --silent < enwik8.orz0 >enwik8.unorz0) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz0.dec_time
(time target/release/orz encode --silent -l1 < enwik8 >enwik8.orz1) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz1.enc_time
(time target/release/orz decode --silent < enwik8.orz1 >enwik8.unorz1) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz1.dec_time
(time target/release/orz encode --silent -l2 < enwik8 >enwik8.orz2) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz2.enc_time
(time target/release/orz decode --silent < enwik8.orz2 >enwik8.unorz2) 2>&1 | grep -Poi 'real\s+\K[0-9.ms]+' >orz2.dec_time
cmp enwik8.unorz0 enwik8
cmp enwik8.unorz1 enwik8
cmp enwik8.unorz2 enwik8
- name: "==================== Benchmark Result ===================="
run: |
echo ""
printf "| | %16s | %12s | %12s |\n" "Compressed Size" "Encode time" "Decode time"
printf "|-----------|------------------|--------------|--------------|\n"
(
printf "| gzip -9 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.gz | grep -Poi '\d+')" "$(cat < gzip.enc_time)" "$(cat < gzip.dec_time)"
printf "| bzip2 -9 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.bz2 | grep -Poi '\d+')" "$(cat < bzip2.enc_time)" "$(cat < bzip2.dec_time)"
printf "| brotli -6 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.br6 | grep -Poi '\d+')" "$(cat < br6.enc_time)" "$(cat < br6.dec_time)"
printf "| brotli -9 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.br9 | grep -Poi '\d+')" "$(cat < br9.enc_time)" "$(cat < br9.dec_time)"
printf "| zstd -10 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.zstd10 | grep -Poi '\d+')" "$(cat < zstd10.enc_time)" "$(cat < zstd10.dec_time)"
printf "| zstd -15 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.zstd15 | grep -Poi '\d+')" "$(cat < zstd15.enc_time)" "$(cat < zstd15.dec_time)"
printf "| zstd -19 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.zstd19 | grep -Poi '\d+')" "$(cat < zstd19.enc_time)" "$(cat < zstd19.dec_time)"
printf "| orz -l0 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.orz0 | grep -Poi '\d+')" "$(cat < orz0.enc_time)" "$(cat < orz0.dec_time)"
printf "| orz -l1 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.orz1 | grep -Poi '\d+')" "$(cat < orz1.enc_time)" "$(cat < orz1.dec_time)"
printf "| orz -l2 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.orz2 | grep -Poi '\d+')" "$(cat < orz2.enc_time)" "$(cat < orz2.dec_time)"
printf "| xz -6 | %16s | %12s | %12s |\n" "$(wc -c < enwik8.xz | grep -Poi '\d+')" "$(cat < xz.enc_time)" "$(cat < xz.dec_time)"
) | sort -n -k4