3 # SPDX-License-Identifier: GPL-2.0
7 temp_dir
=$
(mktemp
-d /tmp
/perf-test-script.XXXXXXXXXX
)
9 perfdatafile
="${temp_dir}/perf.data"
10 db_test
="${temp_dir}/db_test.py"
17 sane
=$
(echo "${temp_dir}" | cut
-b 1-21)
18 if [ "${sane}" = "/tmp/perf-test-script" ] ; then
19 echo "--- Cleaning up ---"
20 rm -rf "${temp_dir:?}/"*
31 trap trap_cleanup EXIT TERM INT
38 # Check if python script is supported
39 if perf version
--build-options |
grep python |
grep -q OFF
; then
40 echo "SKIP: python scripting is not supported"
45 cat << "_end_of_file_" > "${db_test}"
46 perf_db_export_mode
= True
47 perf_db_export_calls
= False
48 perf_db_export_callchains
= True
50 def sample_table
(*args
):
51 print
(f
'sample_table({args})')
53 def call_path_table
(*args
):
54 print
(f
'call_path_table({args}')
58 cmd_flags
="--call-graph dwarf -e cpu-clock";;
63 perf record
$cmd_flags -o "${perfdatafile}" true
64 # Disable lsan to avoid warnings about python memory leaks.
65 export ASAN_OPTIONS
=detect_leaks
=0
66 perf
script -i "${perfdatafile}" -s "${db_test}"
68 echo "DB test [Success]"
73 echo "parallel-perf test"
74 if ! python3
--version >/dev
/null
2>&1 ; then
75 echo "SKIP: no python3"
79 pp
=$
(dirname "$0")/..
/..
/scripts
/python
/parallel-perf.py
80 if [ ! -f "${pp}" ] ; then
81 echo "SKIP: parallel-perf.py script not found "
85 perf_data
="${temp_dir}/pp-perf.data"
86 output1_dir
="${temp_dir}/output1"
87 output2_dir
="${temp_dir}/output2"
88 perf record
-o "${perf_data}" --sample-cpu uname
89 python3
"${pp}" -o "${output1_dir}" --jobs 4 --verbose -- perf script -i "${perf_data}"
90 python3
"${pp}" -o "${output2_dir}" --jobs 4 --verbose --per-cpu -- perf script -i "${perf_data}"
91 echo "parallel-perf test [Success]"