diff --git a/.github/workflows/perf-statistic.yml b/.github/workflows/perf-statistic.yml index ce368fbf1..7e66f900d 100644 --- a/.github/workflows/perf-statistic.yml +++ b/.github/workflows/perf-statistic.yml @@ -45,6 +45,9 @@ jobs: env: CC: gcc-12 CXX: g++-12 + - name: Run perf count checker + run: | + source scripts/run_perf_count_checker.sh - name: Run perf tests run: | source scripts/generate_perf_results.sh diff --git a/scripts/run_perf_count_checker.sh b/scripts/run_perf_count_checker.sh new file mode 100644 index 000000000..180b1d695 --- /dev/null +++ b/scripts/run_perf_count_checker.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +REQUIRED_TESTS_COUNT=2 + +get_ref_tests_number() { + # shellcheck disable=SC2155 + local dir_number=$(find "$1" -maxdepth 1 -type d | wc -l) + # shellcheck disable=SC2004 + local task_number=$(($dir_number-1)) + # shellcheck disable=SC2004 + local tests_coeff=$(($REQUIRED_TESTS_COUNT+1)) + # shellcheck disable=SC2004 + local ref_tests_number=$(($task_number * $tests_coeff)) + echo "$ref_tests_number" +} + +get_current_tests_number() { + # shellcheck disable=SC2155 + local ref_tests_number="$("$1" --gtest_list_tests | wc -l)" + # shellcheck disable=SC2004 + ref_tests_number=$(($ref_tests_number+0)) + echo "$ref_tests_number" +} + +get_error_msg() { + echo "Count of perf tests in $1 != $REQUIRED_TESTS_COUNT" +} + +run_check() { + # shellcheck disable=SC2155 + # shellcheck disable=SC2004 + local ref_num="$(get_ref_tests_number "tasks/$1" $(($REQUIRED_TESTS_COUNT+1)))" + # shellcheck disable=SC2155 + local curr_num="$(get_current_tests_number "./build/bin/$1_perf_tests")" + + if [[ ref_num -ne curr_num ]]; then + # shellcheck disable=SC2005 + echo "$(get_error_msg "$1")" + exit 1 + fi +} + +run_check "mpi" +run_check "omp" +run_check "seq" +run_check "stl" +run_check "tbb" + +echo "Success - perf count tests"