-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperftest
executable file
·61 lines (54 loc) · 1.25 KB
/
perftest
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
#!/bin/sh
#
# SPDX-License-Identifier: LGPL-2.1-only
#
# do a quick performance test of pseudo
opt_f=false
flag_f=
while getopts "f" o
do
case $o in
f) opt_f=true
flag_f=-f
;;
\?) die "Usage: perftest [-f] [directory]";;
esac;
done
shift `expr $OPTIND - 1`
die() {
printf "%s\n" "$*" >&2
exit 1
}
doit() (
cd $dir
printf "%s\n" "Making test data..."
time ./makedata
printf "%s\n" "Timing tar command."
time sh -c 'tar cf - dir_[0-9] | tar -C new -xf -'
printf "%s\n" "Timing find command."
time find new -perm 0100 -exec true {} +
printf "%s\n" "Timing rm."
time rm -rf dir_[0-9] new
)
[ -x bin/pseudo ] || die "You need a bin/pseudo to test."
case $# in
0) dir="perftest.d";;
1) [ -d "$1" ] || die "Specify an existing directory to test in. '%s' is not a directory." "$1"
dir="$1/perftest.d"
;;
*) die "Usage: perftest [directory]"
;;
esac
if $opt_f || [ `id -u` = x0 ]; then
printf "Running test in %s.\n" "$dir"
doit
printf "Done.\n"
else
[ -d $dir ] && die "Directory '$dir' already exists, delete it if you're done."
mkdir $dir
mkdir -p $dir/new
cc -o $dir/makedata makedata.c
printf "%s\n" "Running performance test (total time at end)"
time bin/pseudo ./perftest -f ${dir%perftest.d}
rm -rf $dir
fi