Skip to content

Commit

Permalink
Fix test_perf.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
mikir committed Jan 22, 2025
1 parent 210ff8f commit ec6306f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 26 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build_linux_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,12 @@ jobs:
- name: Run Zserio custom integration test
run: |
scripts/test_zs.sh cpp-${PACKAGE} -d test/data/others/gif/zs -s gif.zs
- name: Run Zserio performance test
run: |
scripts/test_perf.sh cpp-${PACKAGE} -d test/data/others/gif/zs -s gif.zs -b gif.GifFile \
-f test/data/others/gif/data/1pix.gif -c READ
scripts/test_perf.sh cpp-${PACKAGE} -d test/data/others/gif/zs -s gif.zs -b gif.GifFile \
-f test/data/others/gif/data/1pix.gif -c WRITE
scripts/test_perf.sh cpp-${PACKAGE} -d test/data/others/gif/zs -s gif.zs -b gif.GifFile \
-f test/data/others/gif/data/1pix.gif -c READ_WRITE
9 changes: 9 additions & 0 deletions .github/workflows/build_windows_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,12 @@ jobs:
- name: Run Zserio custom integration test
run: |
scripts/test_zs.sh cpp-${PACKAGE} -d test/data/others/gif/zs -s gif.zs
- name: Run Zserio performance test
run: |
scripts/test_perf.sh cpp-${PACKAGE} -d test/data/others/gif/zs -s gif.zs -b gif.GifFile \
-f test/data/others/gif/data/1pix.gif -c READ
scripts/test_perf.sh cpp-${PACKAGE} -d test/data/others/gif/zs -s gif.zs -b gif.GifFile \
-f test/data/others/gif/data/1pix.gif -c WRITE
scripts/test_perf.sh cpp-${PACKAGE} -d test/data/others/gif/zs -s gif.zs -b gif.GifFile \
-f test/data/others/gif/data/1pix.gif -c READ_WRITE
56 changes: 30 additions & 26 deletions scripts/test_perf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -368,40 +368,44 @@ test_perf()
local SWITCH_RUN_ONLY="$1"; shift
local SWITCH_PROFILE="$1"; shift

# run C++ performance test
local TEST_SRC_DIR="${TEST_OUT_DIR}/src"
mkdir -p "${TEST_SRC_DIR}"
local TEST_SRC_FILE="${TEST_SRC_DIR}/PerformanceTest.cpp"
local TEST_LOG_DIR="${TEST_OUT_DIR}/log"
mkdir -p "${TEST_LOG_DIR}"
if [[ ${SWITCH_RUN_ONLY} == 0 ]] ; then
generate_performance_test "${TEST_SRC_FILE}" "${SWITCH_BLOB_NAME}" \
"${SWITCH_JSON_FILE}" "${SWITCH_BLOB_FILE}" "${TEST_LOG_DIR}/PerformanceTest.log" \
${SWITCH_NUM_ITERATIONS} ${SWITCH_TEST_CONFIG} ${SWITCH_PROFILE}
fi
# run C++ performance tests
local CMAKE_ARGS=()
local CTEST_ARGS=("--verbose")
if [[ ${SWITCH_PROFILE} == 1 ]] ; then
CMAKE_ARGS=("-DCMAKE_BUILD_TYPE=RelWithDebInfo")
CTEST_ARGS+=("-T memcheck")
fi
local TEST_LOG_FILE_SUBDIR="log"
local TEST_LOG_FILE_NAME="PerformanceTest.log"
for CPP_TARGET in "${CPP_TARGETS[@]}" ; do
local TARGET_TEST_OUT_DIR="${TEST_OUT_DIR}/${CPP_TARGET}"
local TEST_SRC_DIR="${TARGET_TEST_OUT_DIR}/src"
mkdir -p "${TEST_SRC_DIR}"
local TEST_SRC_FILE="${TEST_SRC_DIR}/PerformanceTest.cpp"
local TEST_LOG_DIR="${TARGET_TEST_OUT_DIR}/${TEST_LOG_FILE_SUBDIR}"
mkdir -p "${TEST_LOG_DIR}"
mkdir -p "${TARGET_TEST_OUT_DIR}"
if [[ ${SWITCH_RUN_ONLY} == 0 ]] ; then
generate_performance_test "${TEST_SRC_FILE}" "${SWITCH_BLOB_NAME}" \
"${SWITCH_JSON_FILE}" "${SWITCH_BLOB_FILE}" "${TEST_LOG_DIR}/${TEST_LOG_FILE_NAME}" \
${SWITCH_NUM_ITERATIONS} ${SWITCH_TEST_CONFIG} ${SWITCH_PROFILE}
fi

# run test
test_zs "${ZSERIO_CPP17_DISTR_DIR}" "${ZSERIO_CPP17_PROJECT_ROOT}" "${ZSERIO_CPP17_BUILD_DIR}" \
"${TEST_OUT_DIR}" PARAM_CPP_TARGET_ARRAY[@] "${SWITCH_SOURCE}" "${SWITCH_DIRECTORY}" \
"${SWITCH_TEST_NAME}" "${TEST_SRC_FILE}"
if [ $? -ne 0 ] ; then
return 1
fi
# run external integration test
test_zs "${ZSERIO_CPP17_DISTR_DIR}" "${ZSERIO_CPP17_PROJECT_ROOT}" "${ZSERIO_CPP17_BUILD_DIR}" \
"${TEST_OUT_DIR}" CPP_TARGET "${SWITCH_SOURCE}" "${SWITCH_DIRECTORY}" \
"${SWITCH_TEST_NAME}" "${TEST_SRC_FILE}"
if [ $? -ne 0 ] ; then
return 1
fi

if [[ ${SWITCH_PROFILE} == 1 ]] ; then
echo
echo "C++ profiling finished, use one of the following commands for analysis:"
for CPP_TARGET in "${CPP_TARGETS[@]}" ; do
local CALLGRIND_FILE=$(${FIND} "${TEST_OUT_DIR}/cpp/${CPP_TARGET}" -name "callgrind.out")
if [[ ${SWITCH_PROFILE} == 1 ]] ; then
echo
echo "C++ profiling finished, use the following commands for analysis:"
local CALLGRIND_FILE=$(${FIND} "${TARGET_TEST_OUT_DIR}" -name "callgrind.out")
echo " kcachegrind ${CALLGRIND_FILE}"
done
fi
fi
done

# collect results
echo
Expand All @@ -417,7 +421,7 @@ test_perf()
"Generator" "Total Duration" "Iterations" "Step Duration" "Blob Size" "Blob in Memory"
echo -n "|" ; for i in {1..101} ; do echo -n "-" ; done ; echo "|"
for CPP_TARGET in "${CPP_TARGETS[@]}" ; do
local PERF_TEST_FILE=$(${FIND} "${TEST_OUT_DIR}/cpp/${CPP_TARGET}" -name "PerformanceTest.log")
local PERF_TEST_FILE="${TEST_OUT_DIR}/${CPP_TARGET}/${TEST_LOG_FILE_SUBDIR}/${TEST_LOG_FILE_NAME}"
local RESULTS=($(cat ${PERF_TEST_FILE}))
printf "| %-21s | %14s | %10s | %15s | %10s | %14s |\n" \
"C++ (${CPP_TARGET})" ${RESULTS[0]} ${RESULTS[1]} ${RESULTS[2]} ${RESULTS[3]} ${RESULTS[4]}
Expand Down

0 comments on commit ec6306f

Please sign in to comment.