diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-10-14 08:31:27 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-10-14 08:31:27 +0000 |
commit | 60cb5be04ecd313f4ea508f66951957d9644fa01 (patch) | |
tree | 0476596ab25071688c71d5f17d86d74951ad391f /bench.sh | |
parent | 3bf30d8b66bef6ad739a9dedff6ff73bde521866 (diff) | |
parent | 560b481f8edd11aaa012204e4798b9d549df685e (diff) | |
download | obnam2-60cb5be04ecd313f4ea508f66951957d9644fa01.tar.gz |
Merge branch 'bench' into 'main'
add a single-file benchmark
Closes #96
See merge request obnam/obnam!187
Diffstat (limited to 'bench.sh')
-rwxr-xr-x | bench.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/bench.sh b/bench.sh new file mode 100755 index 0000000..75cd459 --- /dev/null +++ b/bench.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# Run a simple benchmark of an initial backup of a sparse file of a +# given size. This mainly measures how fast the client can split the +# live data into chunks and compute checksums for the chunks. +# +# 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 + +SIZE=1G + +TMP="$(mktemp -d)" +trap 'rm -rf "$TMP"' EXIT + +chunks="$TMP/chunks" +live="$TMP/live" + +mkdir "$chunks" +mkdir "$live" +truncate --size "$SIZE" "$live/data.dat" + +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 +if true; then + /usr/bin/time 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 -9 "$pid" |