aboutsummaryrefslogtreecommitdiff
path: root/benchmark.bash
blob: 61926dfbd4d99c776ce4d0a4c98e7238d0dd2006 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash -eu

# Run the set of "canonical" benchmarks that are shown on
# https://nuetzlich.net/gocryptfs/comparison/

cd "$(dirname "$0")"
MYNAME=$(basename "$0")

function usage {
	echo "Usage: $MYNAME [-encfs] [DIR]"
	exit 1
}

# Print help text on too many arguments or "-h"
if [[ $# -gt 2 ]]; then
	usage
elif [[ $# -ge 1 ]] && [[ $1 == "-h" ]]; then
	usage
fi

# Set $DIR and $MODE
MODE=gocryptfs
DIR=/tmp
if [[ $# -eq 2 ]]; then
	if [[ $1 != "-encfs" ]]; then
		usage
	fi
	MODE=encfs
	DIR=$2
elif [[ $# -eq 1 ]]; then
	if [[ $1 == "-encfs" ]]; then
		MODE=encfs
	else
		DIR=$1
	fi
fi

# Create directories
CRYPT=$(mktemp -d "$DIR/$MYNAME.XXX")
MNT=$CRYPT.mnt
mkdir $MNT

# Mount
if [[ $MODE == encfs ]]; then
	echo "Testing EncFS at $CRYPT"
	encfs --extpass="echo test" --standard $CRYPT $MNT > /dev/null
else
	echo "Testing gocryptfs at $CRYPT"
	gocryptfs -q -init -extpass="echo test" -scryptn=10 $CRYPT
	# By default, gocryptfs decides between OpenSSL and Go GCM:
	gocryptfs -q -extpass="echo test" $CRYPT $MNT
	# Force use of OpenSSL:
	#gocryptfs -q -extpass="echo test" -openssl=true $CRYPT $MNT
	# Force use of Go GCM:
	#gocryptfs -q -extpass="echo test" -openssl=false $CRYPT $MNT
fi

# Cleanup trap
trap "cd /; fusermount -u -z $MNT; rm -rf $CRYPT $MNT" EXIT

# Benchmarks
./tests/canonical-benchmarks.bash $MNT