memgraph/tests/feature_benchmark/ha/runner.sh
Matija Santl aba360968c Change HA benchmark to run for a fixed amount of time
Summary:
In order to get more consistent results, give the benchmark a certain
amount of time it is supposed to run and not the number of queries.

The resluts on my machine are as following:
```
duration 10.0004
executed_writes 25190
write_per_second 2518.91
duration 10.0005
executed_writes 25096
write_per_second 2509.48
duration 10.0004
executed_writes 23068
write_per_second 2306.7
duration 10.0006
executed_writes 26390
write_per_second 2638.84
duration 10.0008
executed_writes 26246
write_per_second 2624.38
duration 10.0006
executed_writes 24752
write_per_second 2475.06
duration 10.0027
executed_writes 24818
write_per_second 2481.14
duration 10.0032
executed_writes 25148
write_per_second 2513.99
duration 10.0009
executed_writes 25075
write_per_second 2507.28
duration 10.0008
executed_writes 25846
write_per_second 2584.4
duration 10.0006
executed_writes 25671
write_per_second 2566.96
duration 10.0025
executed_writes 25983
write_per_second 2597.65
```

Reviewers: ipaljak

Reviewed By: ipaljak

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1812
2019-01-17 10:07:44 +01:00

72 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
function echo_info { printf "\033[1;36m~~ $1 ~~\033[0m\n"; }
function echo_success { printf "\033[1;32m~~ $1 ~~\033[0m\n\n"; }
function echo_failure { printf "\033[1;31m~~ $1 ~~\033[0m\n\n"; }
## Environment setup
# Get script location.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
# Find memgraph binaries.
binary_dir="$DIR/../../../build"
if [ ! -d $binary_dir ]; then
binary_dir="$DIR/../../../build_release"
fi
# Results for apollo
RESULTS="$DIR/.apollo_measurements"
# Benchmark parameters
DURATION=10
## Startup
declare -a HA_PIDS
for server_id in 1 2 3
do
$binary_dir/memgraph_ha --server_id $server_id \
--coordination_config_file="coordination.json" \
--raft_config_file="raft.json" \
--port $((7686 + $server_id)) \
--durability_directory=dur$server_id &
HA_PIDS[$server_id]=$!
done
# Allow some time for leader election.
sleep 3
# Start the memgraph process and wait for it to start.
echo_info "Starting HA benchmark"
$binary_dir/tests/feature_benchmark/ha/benchmark \
--duration=$DURATION \
--output-file=$RESULTS &
pid=$!
wait -n $pid
code=$?
# Shutdown
for server_id in 1 2 3
do
kill -9 ${HA_PIDS[$server_id]}
done
# Cleanup
for server_id in 1 2 3
do
wait -n ${HA_PIDS[$server_id]}
rm -r dur$server_id
done
if [ $code -eq 0 ]; then
echo_success "Benchmark finished successfully"
else
echo_failure "Benchmark didn't finish successfully"
exit $code
fi
exit 0