-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_decompress_zstd.sh
executable file
·78 lines (71 loc) · 1.94 KB
/
_decompress_zstd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# ./_decompress_zstd.sh #test performance for data in default folder "corpus"
# ./_decompress_zstd.sh SilesiaCorpus #test performance for data in folder "SilesiaCorpus"
if [ -z ${basedir:-} ]; then
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
fi
if [ $# -lt 1 ]; then
indir=${basedir}/corpus
else
indir=$1
fi
#### no need to edit subsequent lines
if [[ "$OSTYPE" == "darwin"* ]]; then
echo Make sure to "'"brew install coreutils"'"
shopt -s expand_aliases
alias date='gdate'
fi
#total number of uncompressed bytes
bytes=0
for fx in $(find ${indir}/* -maxdepth 1 -type f); do # only regular file in the current dir
if [[ "$OSTYPE" == "darwin"* ]]; then
sz=$(stat -f%z "$fx")
else
sz=$(stat -c%s "$fx")
fi
if [ ! "${fx##*.}" = "gz" ]; then
bytes=$(($bytes + $sz))
fi
done
outdir=${basedir}/tmp
mkdir -p $outdir
exenam=zstd
rm -rf $outdir/*
nCopy=0
#for lvl in {1,3,6,9,11,13,15,17,19}; do
for lvl in {1,3,6,9,11,13}; do
nCopy=$(($nCopy + 1))
for file in $(find ${indir}/* -maxdepth 1 -type f); do # only regular file in the current dir
if [ ! "${file##*.}" = "gz" ]; then
outnam=$outdir/$lvl${file##*/}.zst
cmd="$exenam -T0 -q -f -k -$lvl $file"
#echo "Running command: '$cmd'"
$cmd
cmd="cp ${file}.zst $outnam"
#echo " '$cmd'"
$cmd
rm ${file}.zst
#exit 1
fi
done
done
#bytesPerMegabyte: you could also choose 1024x1024
bytesPerMegabyte=1000000
#1000 ms per second
scale=$(($nCopy * 1000 * $bytes / $bytesPerMegabyte))
filename=$(basename -- "$exenam")
echo -e "DecompressMethod\tms\tmb/sec"
startTime=$(date +%s%3N)
for file in $(find ${outdir}/* -maxdepth 1 -type f); do # only regular file in the current dir
if [ "${file##*.}" = "zst" ]; then
cmd="$exenam -T0 -q -f -k -d $file"
#echo "Running command: '$cmd'"
$cmd
fi
done
ms=$(($(date +%s%3N)-$startTime))
mbs=$(($scale / $ms))
echo -e "$filename\t$ms\t$mbs"
#cleanup - remove temporary folder
rm -rf $outdir
exit 0