diff --git a/other/docker/perf/Dockerfile b/other/docker/perf/Dockerfile new file mode 100644 index 00000000..96486acf --- /dev/null +++ b/other/docker/perf/Dockerfile @@ -0,0 +1,16 @@ +FROM alpine:3.14.0 + +RUN ["apk", "add", "--no-cache", \ + "bash", \ + "gcc", \ + "linux-headers", \ + "msgpack-c-dev", \ + "musl-dev", \ + "libsodium-dev", \ + "libvpx-dev", \ + "opus-dev", \ + "perf"] + +WORKDIR /work +COPY other/docker/perf/entrypoint.sh / +ENTRYPOINT ["/entrypoint.sh"] diff --git a/other/docker/perf/entrypoint.sh b/other/docker/perf/entrypoint.sh new file mode 100755 index 00000000..e4ad71a3 --- /dev/null +++ b/other/docker/perf/entrypoint.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -eux + +TEST=${1:-conference_test} +OUTPUT="/work/c-toxcore/test.perf" + +readarray -t FLAGS <<<"$(pkg-config --cflags --libs libsodium msgpack opus vpx | sed -e 's/ /\n/g')" +readarray -t SRCS <<<"$(find /work/c-toxcore/tox* -name "*.c")" + +gcc -pthread -g \ + -o "/work/$TEST" -O3 -fno-omit-frame-pointer \ + "${SRCS[@]}" \ + /work/c-toxcore/auto_tests/auto_test_support.c \ + /work/c-toxcore/testing/misc_tools.c \ + "/work/c-toxcore/auto_tests/$TEST.c" \ + -DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \ + "${FLAGS[@]}" + +time perf record -g --call-graph dwarf --freq=max "/work/$TEST" /work/c-toxcore/auto_tests/ +perf report | head -n50 +perf script -F +pid >"$OUTPUT" +chown 1000:100 "$OUTPUT" diff --git a/other/docker/perf/run b/other/docker/perf/run new file mode 100755 index 00000000..44f336ca --- /dev/null +++ b/other/docker/perf/run @@ -0,0 +1,9 @@ +#!/bin/sh + +set -eux + +docker build -t toxchat/c-toxcore:perf -f other/docker/perf/Dockerfile . +docker run --privileged --rm -it \ + -v "$PWD:/work/c-toxcore" \ + toxchat/c-toxcore:perf \ + "$@"