summaryrefslogtreecommitdiff
path: root/bench-manyfiles.sh
blob: 39e6c2e7bb276016ec50ed90b2d779ca87530bce (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
#!/bin/bash
#
# Run a simple benchmark of an incremental backup of many empty files,
# when the live data hasn't changed.
#
# Edit the if-statement towards the end to get a flamegraph to see
# where time is actually spent.
#
# This is very simplistic and could do with a lot of improvement. But
# it's a start.

set -euo pipefail

N=100000

TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT

chunks="$TMP/chunks"
live="$TMP/live"

mkdir "$chunks"
mkdir "$live"
python3 manyfiles.py "$live" "$N"

cat <<EOF >"$TMP/server.yaml"
address: localhost:8888
chunks: $chunks
tls_key: test.key
tls_cert: test.pem
EOF

cat <<EOF >"$TMP/client.yaml"
server_url: https://localhost:8888
verify_tls_cert: false
roots:
  - $live
log: $TMP/client.log
EOF

cargo build -q --release --all-targets

OBNAM_SERVER_LOG=error cargo run -q --release --bin obnam-server -- "$TMP/server.yaml" >/dev/null &
pid="$!"

cargo run -q --release --bin obnam -- --config "$TMP/client.yaml" init --insecure-passphrase=hunter2

# Initial backup.
cargo run -q --release --bin obnam -- --config "$TMP/client.yaml" backup >/dev/null

# Incremental backup.
if true; then
	/usr/bin/time --format=%e cargo run -q --release --bin obnam -- --config "$TMP/client.yaml" backup >/dev/null
else
	cargo flamegraph --bin obnam -o obnam.svg -- --config "$TMP/client.yaml" backup >/dev/null
fi

kill "$pid"