use dd and lmdd for proper direct/buffered IO on linux and irix
[xfstests-dev.git] / run.tar
1 #!/bin/sh
2
3 # Produces a .tar file (if one doesn't exist as $TARFILE), then
4 # times how long it takes to untar it onto the current directory.
5
6 TARFILE=${TARFILE:=/var/tmp/bench.tar.gz}
7
8 barf()
9 {
10         echo $@ >2
11         exit 1
12 }
13
14 new_tar()
15 {
16         source="bin sbin lib"
17         if [ ! -f $TARFILE ]; then
18                 ( cd / && tar czf $TARFILE $source ) || barf "tar cz failed"
19         fi
20 }
21
22 run_tar()
23 {
24         # %U=user %S=system %E=elapsed
25         mkdir ./tar || exit 1
26         size=`ls -Llh $TARFILE | awk '{print $5}'`
27         time=`/usr/bin/time -f '%U, %S, %E' tar xzf $TARFILE 2>&1`
28         status=$?
29         cd ..
30         rm -fr ./tar
31         [ $status -eq 0 ] || exit 1
32         printf "%6s, %s\n" "$size" "$time"
33 }
34
35 if [ $# -gt 0 ]; then
36         printf "%6s,%5s,%5s,%8s\n" sz usr sys real
37         exit 0
38 fi
39 new_tar
40 run_tar