Skip to content

Commit cdca4e0

Browse files
committed
Refactor performance test parameter handling.
Simplify `ExecuteTest` by encapsulating parameters into a single struct. This reduces redundancy and improves code readability across test execution functions. Updated affected test cases to align with the new parameter structure.
1 parent d4ed8d3 commit cdca4e0

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

modules/core/util/include/test_util.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
3838
virtual bool CheckTestOutputData(OutType& output_data) = 0;
3939
virtual InType GetTestInputData() = 0;
4040

41-
void ExecuteTest(ppc::core::PerfResults::TypeOfRunning mode,
42-
std::function<ppc::core::TaskPtr<InType, OutType>(InType)> task_getter, std::string test_name) {
41+
void ExecuteTest(const PerfTestParam<InType, OutType>& perfTestParam) {
42+
auto task_getter = std::get<ppc::util::FuncTestParamIndex::kTaskGetter>(perfTestParam);
43+
auto test_name = std::get<ppc::util::FuncTestParamIndex::kNameTest>(perfTestParam);
44+
auto mode = std::get<ppc::util::FuncTestParamIndex::kAddParams>(perfTestParam);
45+
4346
task_ = task_getter(GetTestInputData());
4447
ppc::core::Perf perf(task_);
4548
ppc::core::PerfAttr perf_attr;

tasks/example/tests/perf_tests/main.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,7 @@ class ExampleRunPerfTest : public ppc::util::BaseRunPerfTests<InType, OutType> {
4343
InType GetTestInputData() final { return input_data_; }
4444
};
4545

46-
TEST_P(ExampleRunPerfTest, RunModes) {
47-
auto task_getter = std::get<ppc::util::FuncTestParamIndex::kTaskGetter>(GetParam());
48-
auto test_name = std::get<ppc::util::FuncTestParamIndex::kNameTest>(GetParam());
49-
auto perf_type = std::get<ppc::util::FuncTestParamIndex::kAddParams>(GetParam());
50-
ExecuteTest(perf_type, task_getter, test_name);
51-
}
46+
TEST_P(ExampleRunPerfTest, RunPerfModes) { ExecuteTest(GetParam()); }
5247

5348
INSTANTIATE_TEST_SUITE_P_NOLINT(RunModeTests, ExampleRunPerfTest,
5449
::testing::Values(ADD_PERF_MODES(nesterov_a_test_task_all::TestTaskALL, InType),

0 commit comments

Comments
 (0)