-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark_multi.sh
executable file
·58 lines (51 loc) · 1.43 KB
/
benchmark_multi.sh
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
#!/bin/bash
# Must run w/ root-privileges
if [ $# -lt 3 ]; then
echo "Usage: sudo ./benchmark.sh <size-in-MB> <num-files> <cp-executable> [opts]" >&2
exit 0
fi
if [ ! -x "$3" ]; then
echo "Program $3 not found" >&2
exit 1
fi
FILEDIR="rootdir/"
FILEDIRCOPY="rcopy/"
EFILESIZE=`expr $1 \* 1024 \* 1024`
if [ ! -d $FILEDIR ]
then
echo "Benchmark folder doesn't exist, creating one"
python3 generator.py -d 1 -b 0 -n $2 -l $EFILESIZE -m $EFILESIZE
else
FILESIZE=$(stat -c%s "$FILEDIR/file0")
if [ $FILESIZE -ne $EFILESIZE ]
then
echo "Benchmark files have different size, recreating benchmark folder"
rm -r rootdir/
python3 generator.py -d 1 -b 0 -n $2 -l $EFILESIZE -m $EFILESIZE
else
COUNT=$(find "$FILEDIR" -maxdepth 1 -type f | wc -l)
if [ $COUNT -ne $2 ]
then
echo "Benchmark files have different number, recreating benchmark folder"
rm -r rootdir/
python3 generator.py -d 1 -b 0 -n $2 -l $EFILESIZE -m $EFILESIZE
else
echo "Benchmark folder exists"
fi
fi
fi
if [ -d $FILEDIRCOPY ]; then
echo "Deleting existing file copy dir"
rm -r $FILEDIRCOPY
fi
echo "Clearing buffer cache"
sync
echo 3 > /proc/sys/vm/drop_caches
iostat -x -z -k -d 1 > stuff &
if [ $# -gt 3 ]
then
time "$3" -r ${@:4} $FILEDIR $FILEDIRCOPY
else
time "$3" -r $FILEDIR $FILEDIRCOPY
fi
trap 'kill $(jobs -p)' EXIT