2
# tar comparision program
5
n=3 # number of repetitions
6
TAR=(bsdtar gnutar star) # TApeArchivers to compare
7
OPT=("" "--seek" "-no-fsync")
8
pax="--format=pax" # comment out for defaults
9
OPN=(create list extract compare) # operations
11
TIMEFORMAT=$'%R\t%U\t%S\t%P'
15
echo -e "usage:\t$0 source_dir where_to_place_archive
19
TCP stands for Tar Comparision Program here.
20
It currently compares: BSD tar (bsdtar), GNU tar (gnutar) and star in archive
21
creation, listing, extraction and archive-to-extracted comparision.
22
Tcp prints out best time of n=$n repetitions.
24
Tcp creates temporary archive named tcp.tar with $pax and some native
25
(--seek/-no-fsync) options and extracts it to [\$3]/tcptmp/.
26
If unset, third argument defaults to [\$2].
27
After normal exit tcp removes tarball and extracted files.
28
Tcp does not check filesystems destination directories are on for free space,
29
so make sure there is enough space (a bit more than source_dir uses) for both:
30
archive and extracted files.
31
Do not use white space in arguments.
37
dst_path=${3:-$2}/tcptmp
38
test -e $dst -o -e /tmp/tcp \
39
&& { echo "$dst or /tmp/tcp exists, exiting"; exit 1; }
40
mkdir $dst_path || exit 2
44
awk -F"\t" -vN=$n -vL="`du -k $dst`" -vOFS="\t" -vORS="" '
45
{ if (NF==4) { printf "\t%s\t%10.1d KB/s\n", $0, ($1+0>0 ?
46
(L+0)/($1+0) : 0) } }' \
47
/tmp/tcp | sort | head -1
51
test -d $src || { echo "'$src' is not a directory"; exit 3; }
53
# system information: type, release, memory, cpu(s), compiler and flags
54
echo -e "TCP, version $version\n"`uname -sr`" / "`head -1 /etc/*-release`
55
free -m | awk '/^Mem/ { printf "%dMB of memory, ", $2 }'
56
test -e /proc/cpuinfo \
57
&& awk -F: '/name|cache size|MHz|mips/ { if (!a) b=b $2 }
58
/^$/ { a++ } END { print a" x"b" bmips" }' /proc/cpuinfo
59
test -e /etc/gentoo-release \
60
&& gcc --version | head -1 && grep ^CFLAGS /etc/make.conf
64
for tar in [EMAIL PROTECTED]; do echo -ne "$tar:\t"; $tar --version | head -1;
67
echo -e "\nbest time of $n repetitions,\n"\
69
`du -sh $src | awk '{print $1}'`" in "`find $src | wc -l`" files, "\
70
"avg "$((`du -sk $src | awk '{print $1}'`/`find $src -type f | wc
72
" archive=$dst, extract to $dst_path"
74
echo -e "program\toperation\treal\tuser\tsystem\t%CPU\t speed"
77
for op in "cf $dst $pax -C $src ." "tf $dst" "xf $dst -C $dst_path" \
78
"f $dst -C $dst_path --diff"; do
80
for tar in [EMAIL PROTECTED]; do
81
echo -en "$tar\t${OPN[op_num]}\t"
82
for ((i=1; i<=$n; i++)); do
83
echo $op | grep -q ^cf && rm -f $dst
84
echo $op | grep -q ^xf &&
85
{ chmod -R u+w $dst_path
86
rm -rf $dst_path; mkdir $dst_path; }
88
if echo $op | grep -q ^f; then # op == compare
89
time $tar $op ${OPT[$tar_num]} > /dev/null
90
else # op in (create | list | extract)
91
time $tar $op ${OPT[$tar_num]} > /dev/null \
101
rm -rf $dst_path $dst