~sergei.glushchenko/+junk/page-scan-hack

« back to all changes in this revision

Viewing changes to src/libarchive/contrib/psota-benchmark/tcp.sh

merge parallel compression branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# tar comparision program
 
3
# 2007-10-25 Jan Psota
 
4
 
 
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
 
10
version="2007-10-25"
 
11
TIMEFORMAT=$'%R\t%U\t%S\t%P'
 
12
LC_ALL=C
 
13
 
 
14
test $# -ge 2 || {
 
15
        echo -e "usage:\t$0 source_dir where_to_place_archive 
 
16
[where_to_extract_it]
 
17
 
 
18
TCP, version $version
 
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.
 
23
 
 
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.
 
32
        Jan Psota, $version"
 
33
        exit 0
 
34
}
 
35
src=$1
 
36
dst=$2/tcp.tar
 
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
 
41
 
 
42
use_times ()
 
43
{
 
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
 
48
        > /tmp/tcp
 
49
}
 
50
 
 
51
test -d $src || { echo "'$src' is not a directory"; exit 3; }
 
52
 
 
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
 
61
 
 
62
# tar versions
 
63
echo
 
64
for tar in [EMAIL PROTECTED]; do echo -ne "$tar:\t"; $tar --version | head -1; 
 
65
done
 
66
 
 
67
echo -e "\nbest time of $n repetitions,\n"\
 
68
"       src=$src, "\
 
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 
 
71
-l`))"KB/file,\n"\
 
72
"       archive=$dst, extract to $dst_path"
 
73
 
 
74
echo -e "program\toperation\treal\tuser\tsystem\t%CPU\t     speed"
 
75
> /tmp/tcp
 
76
let op_num=0
 
77
for op in "cf $dst $pax -C $src ." "tf $dst" "xf $dst -C $dst_path" \
 
78
        "f $dst -C $dst_path --diff"; do
 
79
        let tar_num=0
 
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; }
 
87
                        sync
 
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 \
 
92
                                        || break 3
 
93
                        fi 2>> /tmp/tcp
 
94
                done
 
95
                use_times
 
96
                let tar_num++
 
97
        done
 
98
        let op_num++
 
99
        echo
 
100
done
 
101
rm -rf $dst_path $dst
 
102
echo
 
103
cat /tmp/tcp
 
104
rm -f /tmp/tcp