2 # $Id: acp.sh 2086 2011-10-27 05:18:01Z jkoshy $
4 # This script is adapted from Jan Psota's Tar Comparison Program(TCP).
6 n=3 # number of repetitions
7 AR="bsdar gnuar" # ar archivers to compare
10 echo "usage: $0 source_dir where_to_place_archive [where_to_extract_it]"
18 test -e $dst -o -e /tmp/acp \
19 && { echo "$dst or /tmp/acp exists, exiting"; exit 1; }
20 mkdir -p $ext || exit 1
24 awk -vL="`du -k $dst`" '{printf "%s\t%s\t%s\%10.1d KB/s\n",
25 $1, $3, $5, ($1>0?L/$1:0)}' /tmp/acp | sort | head -n 1
28 test -d $src || { echo "'$src' is not a directory"; exit 1; }
31 for ar in $AR; do echo -n "$ar: "; $ar -V | head -n 1;
35 echo "best time of $n repetitions"
37 echo -n "`du -sh $src | awk '{print $1}'`"
39 echo "`find $src | wc -l` files"
40 echo " archive=$dst, extract to $ext"
42 echo "program operation real user system speed"
43 for op in "cru $dst $src/*" "t $dst" "x `basename $dst`"; do
46 echo $op | grep -q ^cr && echo -n "create "
47 echo $op | grep -q ^t && echo -n "list "
48 echo $op | grep -q ^x && echo -n "extract "
50 while [ $num -lt $n ]; do
51 echo $op | grep -q ^cr && rm -f $dst
52 echo $op | grep -q ^x && { rm -rf $ext; mkdir -p $ext
53 cp $dst $ext; cd $ext; }
55 time $ar $op > /dev/null 2>> /tmp/acp
56 echo $op | grep -q ^x && cd $THISDIR