Skip to content

Commit 39ba198

Browse files
committed
refactor(python/timing): refactor timing (wip)
1 parent 0e32dda commit 39ba198

File tree

3 files changed

+95
-193
lines changed

3 files changed

+95
-193
lines changed

binding/timing_binding.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,5 @@ void BindTiming(py::module &m) {
4343
.def("get_elapsed_us", &GetElapsedWrapper<std::chrono::microseconds>)
4444
.def("get_elapsed_ms", &GetElapsedWrapper<std::chrono::milliseconds>)
4545
.def("get_elapsed_s", &GetElapsedWrapper<std::chrono::seconds>)
46-
.def("get_elapsed_string", &Timer::GetElapsedString)
47-
.def("__str__", &Timer::GetElapsedString)
48-
.def("__repr__", [](const Timer &self) {
49-
return std::format("<Timer(elapsed='{}') at {}>", self.GetElapsedString(),
50-
static_cast<const void *>(&self));
51-
});
46+
.def("get_elapsed_str", &Timer::GetElapsedString);
5247
}

include/timing/timer.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ class Timer {
109109
*/
110110
void Stop() noexcept { end_time_ = Clock::now(); }
111111

112+
/**
113+
* @brief Reset the timer to start a new measurement
114+
*
115+
* Resets the timer by capturing the current time as the new start point and clearing any
116+
* previously recorded end time. This allows reusing the same timer instance for multiple
117+
* measurements.
118+
*/
119+
void Reset() noexcept {
120+
start_time_ = Clock::now();
121+
end_time_ = TimePoint{};
122+
}
123+
112124
/**
113125
* @brief Get the elapsed time in the specified duration type
114126
*
@@ -166,18 +178,6 @@ class Timer {
166178
*/
167179
[[nodiscard]] auto GetElapsedString() const noexcept -> std::string;
168180

169-
/**
170-
* @brief Reset the timer to start a new measurement
171-
*
172-
* Resets the timer by capturing the current time as the new start point and clearing any
173-
* previously recorded end time. This allows reusing the same timer instance for multiple
174-
* measurements.
175-
*/
176-
void Reset() noexcept {
177-
start_time_ = Clock::now();
178-
end_time_ = TimePoint{};
179-
}
180-
181181
private:
182182
TimePoint start_time_; ///< The time point when timing started
183183
TimePoint end_time_; ///< The time point when timing stopped

0 commit comments

Comments
 (0)