File: run-benchmark

package info (click to toggle)
sshuttle 1.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 920 kB
  • sloc: python: 6,313; sh: 361; makefile: 161
file content (40 lines) | stat: -rwxr-xr-x 827 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"

function with_set_x() {
    set -x
    "$@"
    {
        ec=$?
        set +x
        return $ec
    } 2>/dev/null
}

function log() {
    echo "$*" >&2
}

./test-bed up -d

benchmark() {
    log -e "\n======== Benchmarking sshuttle | Args: [$*]  ========"
    local node=$1
    shift
    with_set_x ./exec-sshuttle "$node" --listen 55771 "$@" &
    sshuttle_pid=$!
    trap 'kill -0 $sshuttle_pid &>/dev/null && kill -15 $sshuttle_pid' EXIT
    while ! nc -z localhost 55771; do sleep 0.1; done
    sleep 1
    ./exec-tool iperf3 "$node" --time=4
    with_set_x kill -15 $sshuttle_pid
    wait $sshuttle_pid || true
}

if [[ $# -gt 0 ]]; then
    benchmark "${@}"
else
    benchmark node-1 --sshuttle-bin="${SSHUTTLE_BIN:-sshuttle}"
    benchmark node-1 --sshuttle-bin=dev
fi