Skip to content

Commit

Permalink
test: Add a profiling script and Dockerfile.
Browse files Browse the repository at this point in the history
This works on my kernel. If your kernel is older/newer, you may need a
different alpine base image that matches your kernel more closely.
  • Loading branch information
iphydf committed Feb 18, 2022
1 parent fde2a7d commit 4389c71
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
16 changes: 16 additions & 0 deletions other/docker/perf/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
23 changes: 23 additions & 0 deletions other/docker/perf/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions other/docker/perf/run
Original file line number Diff line number Diff line change
@@ -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 \
"$@"

0 comments on commit 4389c71

Please sign in to comment.