gobject/performance: improve "performance-run.sh" script

- fix and improve usage output for "performance-run.sh" script.

- add a sleep after compilation. It seems to me, that the first run
  usually performs better, which might be because the temperature of the
  CPU raises and the CPU gets throttled. Unclear whether that is really
  the case, but add a sleep so that all runs start under similar
  conditions where the CPU was idle for a moment.
This commit is contained in:
Thomas Haller 2024-03-19 08:58:01 +01:00
parent 1c9d54d4ea
commit 201628f87f

View File

@ -11,11 +11,14 @@
# #
# 1) configure the build. For example run # 1) configure the build. For example run
# $ git clean -fdx # $ git clean -fdx
# $ meson build -Dprefix=/tmp/glib/ -Db_lto=true --buildtype release -Ddebug=true # $ meson build -Dprefix=/tmp/glib/ -Db_lto=true --buildtype release -Ddebug=false
# Beware, that running the script will check out other commits, # Beware, that running the script will check out other commits,
# build the tree and run `ninja install`. Don't have important # build the tree and run `ninja install`. Don't have important
# work there. # work there.
# #
# Consider setting `echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor`
# and check `watch cat /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_cur_freq`.
#
# 2) run the script. Set $COMMITS to the list of commit sha's to test. # 2) run the script. Set $COMMITS to the list of commit sha's to test.
# Environment variables: # Environment variables:
# COMMITS: list of git references to test. # COMMITS: list of git references to test.
@ -33,23 +36,23 @@
# #
# # once: # # once:
# git clean -fdx # git clean -fdx
# meson build -Dprefix=/tmp/glib/ -Db_lto=true --buildtype release -Ddebug=true # meson build -Dprefix=/tmp/glib/ -Db_lto=true --buildtype release -Ddebug=false
# #
# # test: # # test:
# COMMIT_END=my-test-branch # COMMIT_END=my-test-branch
# COMMIT_START="$(git merge-base origin/main "$COMMIT_END")" # COMMIT_START="$(git merge-base origin/main "$COMMIT_END")"
# PERF="" PATCH="" COMMITS=" $COMMIT_START $COMMIT_END " /tmp/performance-run.sh -s 5 # PERF="" PATCH="" COMMITS=" $COMMIT_START $COMMIT_END " /tmp/performance-run.sh -q -s 5
# PERF="" PATCH="" COMMITS=" $COMMIT_START $( git log --reverse --pretty=%H "$COMMIT_START..$COMMIT_END" ) " /tmp/performance-run.sh -s 5 # PERF="" PATCH="" COMMITS=" $COMMIT_START $( git log --reverse --pretty=%H "$COMMIT_START..$COMMIT_END" ) " /tmp/performance-run.sh -q -s 5
# #
# GLIB_PERFORMANCE_FACTOR=17.06 PERF='perf stat -r 3 -B' PATCH="" COMMITS=" $COMMIT_START $COMMIT_END " /tmp/performance-run.sh -s 1 property-get # GLIB_PERFORMANCE_FACTOR=1 PERF='perf stat -r 3 -B' PATCH="" COMMITS=" $COMMIT_START $COMMIT_END " /tmp/performance-run.sh -q -s 1 property-get
set -e set -e
usage() { usage() {
sed -n '4,/^$/ s/^#\( \(.*\)\|\)$/\2/p' "$0" sed -n '/^# Run /,/^$/ s/^#\( \(.*\)\|\)$/\2/p' "$0"
} }
if [ "$#" -eq 1 ] && [ "$1" == "-h" ] ; then if [[ "$#" -eq 1 && ( "$1" == "-h" || "$1" == "--help" ) ]]; then
usage usage
exit 0 exit 0
fi fi
@ -92,7 +95,7 @@ Testing commits:
$(_list_commits " ") $(_list_commits " ")
\$ meson build -Dprefix=/tmp/glib/ -Db_lto=true --buildtype release -Ddebug=true \$ meson build -Dprefix=/tmp/glib/ -Db_lto=true --buildtype release -Ddebug=false
\$ PATCH=$(printf '%q' "$PATCH") \\ \$ PATCH=$(printf '%q' "$PATCH") \\
PREPARE_CMD=$(printf '%q' "$PREPARE_CMD") \\ PREPARE_CMD=$(printf '%q' "$PREPARE_CMD") \\
PERF=$(printf '%q' "$PERF") \\ PERF=$(printf '%q' "$PERF") \\
@ -151,6 +154,7 @@ for idx in "${!COMMITS_V[@]}" ; do
# ./build/gobject/tests/performance/performance # ./build/gobject/tests/performance/performance
# ldd ./build/gobject/tests/performance/performance # ldd ./build/gobject/tests/performance/performance
sleep 2
( (
if [ -z "$PERF" ] ; then if [ -z "$PERF" ] ; then
TESTRUN="$I" TESTCOMMIT="$commit" ./build/gobject/tests/performance/performance "$@" TESTRUN="$I" TESTCOMMIT="$commit" ./build/gobject/tests/performance/performance "$@"