Skip to content
This repository was archived by the owner on Sep 3, 2023. It is now read-only.

Commit a9441bf

Browse files
committed
[SHPOS-746] Change vector to array
- Change Preprocessor's std::vector to array for avoiding dynamic memory reallocation - Add debug option Signed-off-by: isaac.baek <isaac.baek@samsung.com>
1 parent d08b74f commit a9441bf

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ add_library(air STATIC ${SOURCE_FILES})
33
target_include_directories(air PUBLIC ${CMAKE_SOURCE_DIR})
44
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)
55
message(STATUS "compile option -fconstexpr-ops-limit is used")
6-
target_compile_options(air PRIVATE -std=c++14 -Wall -Werror -O3 -mavx2 -fPIC -fconstexpr-ops-limit=123456789)
6+
target_compile_options(air PRIVATE -std=c++14 -Wall -Werror -g -O3 -mavx2 -fPIC -fconstexpr-ops-limit=123456789)
77
else()
88
message(STATUS "compile option -fconstexpr-loop-limit is used")
9-
target_compile_options(air PRIVATE -std=c++14 -Wall -Werror -O3 -mavx2 -fPIC -fconstexpr-loop-limit=123456789)
9+
target_compile_options(air PRIVATE -std=c++14 -Wall -Werror -g -O3 -mavx2 -fPIC -fconstexpr-loop-limit=123456789)
1010
endif()
1111
target_link_libraries(air pthread)

src/process/Preprocessor.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,16 @@ process::Preprocessor::_ConvertData(void)
113113
lib::LatencyData* lat_data = data.done_to.back();
114114
for (auto& timelog : lat_data->end_v)
115115
{
116-
data.timelog_to.push_back(timelog);
117-
need_update = true;
116+
if (data.timelog_to_size < MAX_TIMELOG_TO_SIZE - 1)
117+
{
118+
data.timelog_to[data.timelog_to_size] = timelog;
119+
data.timelog_to_size++;
120+
need_update = true;
121+
}
122+
else
123+
{
124+
break;
125+
}
118126
}
119127
data.done_to.pop_back();
120128
}
@@ -138,8 +146,9 @@ process::Preprocessor::_MatchData(void)
138146
}
139147
data.update = false;
140148

141-
for (auto& timelog : data.timelog_to)
149+
for (uint32_t index {0}; index < data.timelog_to_size; index++)
142150
{
151+
auto& timelog {data.timelog_to[index]};
143152
auto it_match = data.timestamp_from.find(timelog.key);
144153
if (it_match != data.timestamp_from.end())
145154
{
@@ -178,7 +187,7 @@ process::Preprocessor::_CleanData(int option)
178187
data.done_from.clear();
179188
data.done_to.clear();
180189
data.timestamp_from.clear();
181-
data.timelog_to.clear();
190+
data.timelog_to_size = 0;
182191
}
183192
match_map.clear();
184193
}

src/process/Preprocessor.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ class Preprocessor
5656
void _MatchData(void);
5757
void _CleanData(int option);
5858

59+
static const uint32_t MAX_TIMELOG_TO_SIZE {100000};
5960
struct match_st
6061
{
6162
std::vector<lib::LatencyData*> done_from;
6263
std::vector<lib::LatencyData*> done_to;
6364
std::map<uint64_t, timespec> timestamp_from;
64-
std::vector<lib::TimeLog> timelog_to;
65+
lib::TimeLog timelog_to[MAX_TIMELOG_TO_SIZE];
66+
uint32_t timelog_to_size {0};
6567
bool done {false};
6668
bool update {false};
6769
};

0 commit comments

Comments
 (0)