Skip to content

Commit e632eb1

Browse files
committed
refactor performance tests: streamline includes, improve initialization, and enhance namespace usage
1 parent 50ec435 commit e632eb1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

modules/performance/tests/perf_tests.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#include <gtest/gtest.h>
22

33
#include <chrono>
4-
#include <cstdint>
54
#include <filesystem>
65
#include <fstream>
76
#include <memory>
87
#include <ostream>
98
#include <stdexcept>
10-
#include <string_view>
9+
#include <string>
1110
#include <thread>
1211
#include <vector>
1312

@@ -56,6 +55,8 @@ class FakePerfTask : public TestPerfTask<InType, OutType> {
5655

5756
namespace ppc::performance {
5857

58+
namespace {
59+
5960
TEST(perf_tests, check_perf_pipeline) {
6061
std::vector<uint32_t> in(2000, 1);
6162

@@ -136,7 +137,7 @@ TEST(perf_tests, check_perf_task_float) {
136137
}
137138

138139
struct ParamTestCase {
139-
PerfResults::TypeOfRunning input;
140+
PerfResults::TypeOfRunning input{};
140141
std::string expected_output;
141142
friend void PrintTo(const ParamTestCase& param, std::ostream* os) {
142143
*os << "{ input = " << static_cast<int>(param.input) << ", expected = " << param.expected_output << " }";
@@ -159,7 +160,7 @@ INSTANTIATE_TEST_SUITE_P(ParamTests, GetStringParamNameParamTest,
159160
});
160161

161162
struct TaskTypeTestCase {
162-
TypeOfTask type;
163+
TypeOfTask type{};
163164
std::string expected;
164165
std::string label;
165166
friend void PrintTo(const TaskTypeTestCase& param, std::ostream* os) {
@@ -441,7 +442,7 @@ TEST(PerfTest, CommonRunCalculatesAverageTime) {
441442
perf.PipelineRun(attr);
442443
auto results = perf.GetPerfResults();
443444

444-
// Total time should be 3 seconds, average should be 1 second (3.0 - 0.0) / 3
445+
// Total time should be 3 seconds, average should be 1 second (3.0-0.0) / 3
445446
EXPECT_DOUBLE_EQ(results.time_sec, 1.0);
446447
}
447448

@@ -573,11 +574,10 @@ TEST(PerfTest, TaskRunCompletesPipelineAfterTiming) {
573574
}
574575

575576
namespace test_namespace {
576-
struct TestType {};
577577
} // namespace test_namespace
578578

579579
TEST(PerfTest, TemplateInstantiationWithDifferentTypes) {
580-
// Test that Perf template can be instantiated with different types
580+
// Test that the Perf template can be instantiated with different types
581581
auto int_task = std::make_shared<DummyTask>();
582582
Perf<int, int> int_perf(int_task);
583583

@@ -616,4 +616,6 @@ TEST(TaskTest, Destructor_InvalidPipelineOrderTerminates_PartialPipeline) {
616616
ppc::util::DestructorFailureFlag::Unset();
617617
}
618618

619+
} // namespace
620+
619621
} // namespace ppc::performance

0 commit comments

Comments
 (0)