Skip to content

Commit

Permalink
Update profile.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
yut23 committed Feb 21, 2024
1 parent 3f84dc3 commit 5d59b6d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tools/cpp/profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ cd -- "$AOC_ROOT/$AOC_YEAR"

read -r -d ' ' day < <(parse_day_args "$1")
num=${2:-1}
log_file="profiling/logs/day${day}_${num}.folded"
raw_log_file="profiling/logs/day${day}_${num}.folded"
log_file="profiling/logs/day${day}_${num}.filtered"
svg_file="profiling/day${day}_${num}.svg"
rev_svg_file="profiling/day${day}_${num}_reversed.svg"

BINARY=build/profile/day$day
make_quiet "$BINARY"
mkdir -p profiling/logs
perf record -g --call-graph dwarf,32768 -F 99 hyperfine --shell none "$BINARY input/day$day/input.txt"
perf script --header -F comm,pid,tid,time,event,ip,sym,dso | inferno-collapse-perf --skip-after main > "$log_file"
perf record -g --call-graph dwarf,64000 -F 99 hyperfine --shell none "$BINARY input/day$day/input.txt"
#perf record -g --call-graph dwarf,64000 -F 99 "$BINARY" "input/day$day/input.txt"
perf script --header -F comm,pid,tid,time,event,ip,sym,dso | stackcollapse-perf.pl > "$raw_log_file"
# skip extra frames between the executable name and main(), and exclude some stacks we don't care about
sed -E -e 's/^(.*;)?(main;.*)/\2/' "$raw_log_file" | grep -vE '^'"day$day"'(;_start|;__.*| [0-9]+)|^hyperfine' > "$log_file"
#if [[ $day == 12 ]]; then
# sed -E -i 's/(;aoc::day12::ConditionRecord::count_arrangements)\1*/\1+/;' "$log_file"
#fi
inferno-flamegraph --inverted --deterministic "$log_file" > "$svg_file"
inferno-flamegraph --reverse --deterministic "$log_file" > "$rev_svg_file"

0 comments on commit 5d59b6d

Please sign in to comment.