-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark_single.sh
executable file
·48 lines (39 loc) · 1004 Bytes
/
benchmark_single.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
#!/bin/bash
# Must run w/ root-privileges
if [ $# -lt 2 ]; then
echo "Usage: sudo ./benchmark.sh <size-in-KB> <cp-executable> [opts]" >&2
exit 0
fi
# if [ ! -x "$2" ]; then
# echo "Program $2 not found" >&2
# exit 1
# fi
FILENAME="_test"
filecopy="_testcopy"
if [ ! -f $FILENAME ]
then
echo "Benchmark file doesn't exist, creating one"
dd if=/dev/urandom of=$FILENAME bs=1M count=$1 status=none
else
FILESIZE=$(stat -c%s "$FILENAME")
EXPECTED=`expr $1 \* 1024`
if [ $FILESIZE -ne $EXPECTED ]
then
echo "Benchmark file has different size, recreating one"
dd if=/dev/urandom of=$FILENAME bs=1M count=$1 status=none
else
echo "Benchmark file exists"
fi
fi
if [ -f $filecopy ]; then
echo "Deleting existing file copy"
rm $filecopy
fi
echo "Clearing buffer cache"
sync && echo 3 > /proc/sys/vm/drop_caches
if [ $# -ge 3 ]
then
strace -c "$2" ${@:3} $FILENAME $filecopy
else
strace -c "$2" $FILENAME $filecopy
fi