Advertisement
sufehmi

XCTB - X Compression Tool Benchmarker

Jul 6th, 2020
1,847
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.39 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #### xctb.sh
  4. #### XCTB - X Compression Tool Benchmarker
  5. #
  6. #### included compressor :
  7. #         pigz gzip bzip2 pbzip2 lrzip rzip64 zstd pixz plzip xz
  8. #
  9. # apt-get install -y pigz gzip bzip2 pbzip2 lrzip rzip zstd pixz plzip
  10. #
  11. #######
  12.  
  13. set -x
  14.  
  15. result=x_benchmark.csv
  16. source=$1
  17. compressor_list=("pigz -f" "gzip -f" "bzip2 -f" "pbzip2 -f" "lrzip -f -D" "rzip -f" "zstd -f --rm" "pixz " "plzip -f" "xz -f")
  18. ext_file=("gz" "gz" "bz2" "bz2" "lrz" "rz" "zst" "xz" "lz" "xz")
  19.  
  20. # clean slate
  21. rm $result
  22. i=0
  23.  
  24. echo \"Compression Tool\",\"Compress Time \(sec\)\",\"Compress Size \(MB\)\",\"Decompress Time \(sec\)\"  >> $result
  25.  
  26. for compress in "${compressor_list[@]}"
  27. do
  28.  
  29.         #### testing compression
  30.         echo '\r\r Testing compression tool : $compress \r'
  31.  
  32.         #### record compression time
  33.         start=`date +%s`
  34.                 $compress $source
  35.         end=`date +%s`
  36.         compress_time=$((end-start))
  37.  
  38.         #### record compression size
  39.         compress_size=$(ls -s --block-size=M $source.* | cut -f1 -d "M")
  40.  
  41.         #### record decompression time  
  42.         start=`date +%s`
  43.                 $compress -d $source.${ext_file[$i]}
  44.         end=`date +%s`
  45.         decompress_time=$((end-start))
  46.  
  47.         echo \"$compress\",\"$compress_time\",\"$compress_size\",\"$decompress_time\" >> $result
  48.         ((i=i+1))
  49.  
  50. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement