perf test: Replace record test workload with thloop
So that it can get rid of requirements for a compiler. $ sudo ./perf test -v 92 92: perf record tests : --- start --- test child forked, pid 740204 Basic --per-thread mode test Basic --per-thread mode test [Success] Register capture test Register capture test [Success] Basic --system-wide mode test Basic --system-wide mode test [Success] Basic target workload test Basic target workload test [Success] test child finished with 0 ---- end ---- perf record tests: Ok Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: James Clark <james.clark@arm.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com> Cc: German Gomez <german.gomez@arm.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Zhengjun Xing <zhengjun.xing@linux.intel.com> Link: https://lore.kernel.org/r/20221116233854.1596378-5-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
69b3529278
commit
0b8ff0ba27
@ -9,17 +9,13 @@ shelldir=$(dirname "$0")
|
|||||||
|
|
||||||
err=0
|
err=0
|
||||||
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
|
perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
|
||||||
testprog=$(mktemp /tmp/__perf_test.prog.XXXXXX)
|
testprog="perf test -w thloop"
|
||||||
testsym="test_loop"
|
testsym="test_loop"
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
rm -rf "${perfdata}"
|
rm -rf "${perfdata}"
|
||||||
rm -rf "${perfdata}".old
|
rm -rf "${perfdata}".old
|
||||||
|
|
||||||
if [ "${testprog}" != "true" ]; then
|
|
||||||
rm -f "${testprog}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
trap - EXIT TERM INT
|
trap - EXIT TERM INT
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,53 +25,6 @@ trap_cleanup() {
|
|||||||
}
|
}
|
||||||
trap trap_cleanup EXIT TERM INT
|
trap trap_cleanup EXIT TERM INT
|
||||||
|
|
||||||
build_test_program() {
|
|
||||||
if ! [ -x "$(command -v cc)" ]; then
|
|
||||||
# No CC found. Fall back to 'true'
|
|
||||||
testprog=true
|
|
||||||
testsym=true
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Build a test program"
|
|
||||||
cat <<EOF | cc -o ${testprog} -xc - -pthread
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
void test_loop(void) {
|
|
||||||
volatile int count = 1000000;
|
|
||||||
|
|
||||||
while (count--)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *thfunc(void *arg) {
|
|
||||||
int forever = *(int *)arg;
|
|
||||||
|
|
||||||
do {
|
|
||||||
test_loop();
|
|
||||||
} while (forever);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
pthread_t th;
|
|
||||||
int forever = 0;
|
|
||||||
|
|
||||||
if (argc > 1)
|
|
||||||
forever = atoi(argv[1]);
|
|
||||||
|
|
||||||
pthread_create(&th, NULL, thfunc, &forever);
|
|
||||||
test_loop();
|
|
||||||
pthread_join(th, NULL);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
test_per_thread() {
|
test_per_thread() {
|
||||||
echo "Basic --per-thread mode test"
|
echo "Basic --per-thread mode test"
|
||||||
if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
|
if ! perf record -o /dev/null --quiet ${testprog} 2> /dev/null
|
||||||
@ -96,8 +45,8 @@ test_per_thread() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# run the test program in background (forever)
|
# run the test program in background (for 30 seconds)
|
||||||
${testprog} 1 &
|
${testprog} 30 &
|
||||||
TESTPID=$!
|
TESTPID=$!
|
||||||
|
|
||||||
rm -f "${perfdata}"
|
rm -f "${perfdata}"
|
||||||
@ -205,8 +154,6 @@ test_workload() {
|
|||||||
echo "Basic target workload test [Success]"
|
echo "Basic target workload test [Success]"
|
||||||
}
|
}
|
||||||
|
|
||||||
build_test_program
|
|
||||||
|
|
||||||
test_per_thread
|
test_per_thread
|
||||||
test_register_capture
|
test_register_capture
|
||||||
test_system_wide
|
test_system_wide
|
||||||
|
Reference in New Issue
Block a user