Skip to content

Commit 560c05b

Browse files
committed
Fix end time assignment in end_region_by_type function for accurate timing
1 parent 37bb473 commit 560c05b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

profiling/energy-profiler/kp_energy_profiler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ void start_region(const std::string& name, RegionType type, uint64_t id) {
5858

5959
// End last region of given type
6060
void end_region_by_type(RegionType type_to_end) {
61-
auto& state = EnergyProfilerState::get_instance();
61+
auto end_time = std::chrono::high_resolution_clock::now();
62+
auto& state = EnergyProfilerState::get_instance();
6263
std::lock_guard<std::mutex> lock(state.get_mutex());
6364
auto& active_regions = state.get_active_regions();
6465
if (active_regions.empty()) return;
@@ -69,7 +70,7 @@ void end_region_by_type(RegionType type_to_end) {
6970
if (it != active_regions.rend()) {
7071
auto region = *it;
7172
active_regions.erase(std::next(it).base());
72-
region.end_time = std::chrono::high_resolution_clock::now();
73+
region.end_time = end_time;
7374
state.get_completed_timings().push_back(region);
7475
}
7576
}

0 commit comments

Comments
 (0)