aboutsummaryrefslogtreecommitdiff
path: root/tests/canonical-benchmarks.bash
blob: 71563ab568bff8f0453da861e9086cca13258841 (plain)
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
#!/bin/bash -eu
#
# Run the set of "canonical" benchmarks that are shown on
# https://nuetzlich.net/gocryptfs/comparison/
# against the directory passed as "$1".
#
# This is called by the top-level script "benchmark.bash".

cd "$(dirname "$0")"
MYNAME=$(basename "$0")
MD5="$PWD/stress_tests/linux-3.0.md5sums"

if [ $# -ne 1 ]; then
	echo "usage: $MYNAME TESTDIR"
	exit 1
fi

# Download /tmp/linux-3.0.tar.gz
./dl-linux-tarball.bash

# cd to TESTDIR
cd "$1"

# Execute command, discard all stdout output, print elapsed time
# (to stderr, unfortunately).
function etime {
	# Make the bash builtin "time" print out only the elapsed wall clock
	# seconds
	TIMEFORMAT=%R
	time "$@" > /dev/null
}

echo -n "WRITE: "
dd if=/dev/zero of=zero bs=131072 count=2000 2>&1 | tail -n 1
sleep 0.1
echo -n "READ:  "
dd if=zero of=/dev/null bs=131072 count=2000 2>&1 | tail -n 1
rm zero
sleep 0.1
echo -n "UNTAR: "
etime tar xzf /tmp/linux-3.0.tar.gz
sleep 0.1
echo -n "MD5:   "
etime md5sum --quiet -c $MD5
sleep 0.1
echo -n "LS:    "
etime ls -lR linux-3.0
sleep 0.1
echo -n "RM:    "
etime rm -Rf linux-3.0