Last active
September 18, 2020 01:51
-
-
Save rprichard/1688de36f0132a40294adb0409189533 to your computer and use it in GitHub Desktop.
unwinder benchmark: lookup unwind info with many libraries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
NDK=/x/android-ndk-r21d | |
LIBUNWIND=/x/llvm-upstream/unwind-arm64-21/lib/libunwind.a | |
CXX="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang++ -fuse-ld=lld $LIBUNWIND" | |
rm -fr out | |
mkdir -p out | |
cat >out/build.ninja <<EOF | |
rule solib | |
command = $CXX \$CXXFLAGS -O2 -static-libstdc++ -fpic -shared -o \$out \$in | |
rule exec | |
command = $CXX \$CXXFLAGS -O2 -static-libstdc++ '-Wl,--rpath,\$\$ORIGIN' -o \$out \$in | |
build libbench_final.so: solib ../final.cpp | |
EOF | |
prev=final | |
all_libs=libbench_final.so | |
for i in $(seq 100 | tac); do | |
i_fmt=$(printf '%03d' $i) | |
echo >>out/build.ninja build libbench_${i_fmt}.so: solib ../transfer.cpp | |
echo >>out/build.ninja ' ' CXXFLAGS = -DSELF=$i_fmt -DNEXT=$prev | |
prev=$i_fmt | |
all_libs="libbench_${i_fmt}.so $all_libs" | |
done | |
echo >>out/build.ninja build main: exec ../main.cpp $all_libs | |
ninja -C out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__attribute__((noinline,weak)) | |
void throw_func() { | |
throw 42; | |
} | |
int func_final() { | |
for (int i = 0; i < 10000; ++i) { | |
try { | |
throw_func(); | |
} catch (int i) { | |
} | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <link.h> | |
#include <stdio.h> | |
int func_001(); | |
int cb(dl_phdr_info* info, size_t, void*) { | |
printf("%s\n", info->dlpi_name); | |
return 0; | |
} | |
int main() { | |
func_001(); | |
//dl_iterate_phdr(cb, nullptr); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
adb shell rm -fr /data/local/tmp/out | |
adb push out /data/local/tmp | |
# consider setting the 'performance' CPU governor for better consistency. | |
#gov=performance | |
#adb root | |
#adb shell 'for pol in /sys/devices/system/cpu/cpufreq/policy*/scaling_governor; do echo $pol was $(cat $pol), setting to '${gov}'; echo '${gov}' > $pol; done' | |
# set CPU affinity for better consistency. | |
#TASKSET="taskset 10" | |
#TASKSET= | |
# build https://tratt.net/laurie/src/multitime/ for Android | |
#adb push /x/multitime-android/multitime /data/local/tmp | |
#adb shell LD_LIBRARY_PATH=/data/local/tmp/out $TASKSET /data/local/tmp/multitime -s0 -n100 /data/local/tmp/out/main | |
# or hack something together -- this command will print one sample | |
adb shell $TASKSET time /data/local/tmp/out/main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define XFUNC_NAME(idx) func_ ## idx | |
#define FUNC_NAME(idx) XFUNC_NAME(idx) | |
int FUNC_NAME(NEXT)(); | |
int FUNC_NAME(SELF)() { | |
return FUNC_NAME(NEXT)() + 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment