Commit 181617d3 authored by Rahix's avatar Rahix
Browse files

feat: Add poor-profiler scripts

The poor-profiler scripts allow profiling card10 (to some degree).

Signed-off-by: Rahix's avatarRahix <>
parent b317ff79
This is a (rather poor) attempt at building a profiler for card10. The
idea is based on the [poor man's profiler](
Essentially, it uses stack-traces gathered using GDB. This means,
execution will be significantly slowed down which might make certain
features of the firmware misbehave. Use with care!
That said, here is how to use it:
1. Configure the profiler by adjusting `nsamples` and `sleeptime` in
(If anyone wants to send a patch which makes this script use proper
commandline args, please do!)
2. Start profiling! Just call
./tools/poor-profiler/ >/tmp/samples
from the firmware repository root.
3. Next, collapse the samples using the
$ ./tools/poor-profiler/ /tmp/samples >/tmp/samples.collapsed
4. Finally, feed the collapsed samples into the Brendan Gregg's
[FlameGraph]( script which
will create an svg you can view (and interact with!) in your browser:
$ /path/to/FlameGraph/ /tmp/samples.collapsed >/tmp/flamegraph.svg
$ firefox /tmpflamegraph.svg
(If you feel that a perl script is not modern enough, you can also use
[`inferno-flamegraph`]( which is
written in Rust ...)
Happy profiling!
#!/usr/bin/env bash
cat "$1" | \
sort | \
uniq -c | \
sort -r -n -k 1,1 | \
sed 's/^ \+\([0-9]\+\) \(.*\)$/\2 \1/g' | \
#!/usr/bin/env bash
for x in $(seq 1 $nsamples); do
printf "Capturing %6u/%u ...\n" "$x" "$nsamples" >&2
arm-none-eabi-gdb -nx -x init.gdb -ex "set pagination 0" -ex "bt" -ex "continue&" -batch build/epicardium/epicardium.elf 2>/dev/null | \
grep -E '^#' | \
tac | \
sed 's/^#[0-9]\+ \+0x.* in \(.*\) (.*$/\1/g;s/^#[0-9]\+ \+\(.*\) (.*$/\1/g' | \
tr '\n' ';' | \
sed 's/^\(.*\);$/\1\n/g'
sleep $sleeptime
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment