test-zig-cc/results/profile.sh

36 lines
1.6 KiB
Bash
Raw Normal View History

2022-12-11 20:54:28 +02:00
#!/bin/bash
set -xeuo pipefail
2022-12-16 05:10:01 +02:00
# set to 1 to enable profiling
profile=
2022-12-11 20:54:28 +02:00
_build() {
2022-12-16 05:10:01 +02:00
if [[ "$profile" == 1 ]]; then
perf=(perf record --call-graph=dwarf -g -o "$HOME/$name.data")
else
perf=()
fi
2022-12-11 20:54:28 +02:00
name=$1
shift
2022-12-16 05:10:01 +02:00
bazel build --color=no --curses=no "$@" //:zigzag-0
bazel clean --color=no --curses=no
bazel shutdown --color=no --curses=no
( "${perf[@]}" bazel --batch build --color=no --curses=no "$@" ... ) |& \
tee "results/${name}.log"
2022-12-11 20:54:28 +02:00
}
_build zigcc-nosandbox --spawn_strategy=local --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28
_build llvm-nosandbox --spawn_strategy=local --extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux
_build zigcc --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28
_build llvm --extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux
_build zigcc-reuse-sandbox-dirs --experimental_reuse_sandbox_directories --platforms=@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.28
_build llvm-reuse-sandbox-dirs --experimental_reuse_sandbox_directories --extra_toolchains=@llvm_toolchain_with_sysroot//:cc-toolchain-x86_64-linux
2022-12-11 20:54:28 +02:00
2022-12-16 05:10:01 +02:00
if [[ $profile == 1 ]]; then
for d in $HOME/*.data; do
f=$(basename "$d")
echo "perf script -i $d | inferno-collapse-perf | inferno-flamegraph > results/${f%data}svg"
done | parallel -v --eta
fi