Skip to content

Commit

Permalink
tests/snapd: add quick/simple benchmark for lxc invocations
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Deziel <[email protected]>
  • Loading branch information
simondeziel committed Nov 4, 2024
1 parent ad44dd2 commit 53d084e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/snapd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ TEST_USER="testuser"
# Install lxd without starting daemon
install_lxd false

test_lxc() {
DURATION="${1}"

echo "Repeatedly call 'lxc help' for ${DURATION} and see how fast/slow it is"
# shellcheck disable=SC2016
ITERATIONS="$(timeout "${DURATION}" bash -c 'i=0; trap "echo \$i" EXIT; while i=$((i+1)); do lxc help >/dev/null; done' || true)"
FORKS_PER_SECOND="$(awk "BEGIN {printf \"%d\n\", ${ITERATIONS}/${DURATION}}")"

# Check that lxc forks/s are not below a certain threshold
if [ "${FORKS_PER_SECOND}" -lt 15 ]; then
echo "::warning::lxc forks/s: ${FORKS_PER_SECOND} (< 15/s)"
else
echo "::notice::lxc forks/s: ${FORKS_PER_SECOND}"
fi
}

# Repeatedly call 'lxc help'
test_lxc 30

# Set preseed via snap
snap set lxd daemon.preseed='{"config": {"core.https_address": "[::]:8443"}}'

Expand Down

0 comments on commit 53d084e

Please sign in to comment.