File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232namespace libsemigroups {
3333 namespace py = pybind11;
3434
35+ namespace {
36+ std::chrono::system_clock::time_point
37+ to_system (std::chrono::high_resolution_clock::time_point tp) {
38+ using namespace std ::chrono;
39+ if constexpr (std::is_same_v<system_clock, high_resolution_clock>) {
40+ return tp;
41+ } else {
42+ // Account for the difference between system_clock and
43+ // high_resolution_clock
44+ auto sys_now = system_clock::now ();
45+ auto high_res_now = high_resolution_clock::now ();
46+ return time_point_cast<system_clock::duration>(tp - high_res_now
47+ + sys_now);
48+ }
49+ }
50+ } // namespace
51+
3552 void init_reporter (py::module & m) {
3653 m.def (
3754 " delta" ,
@@ -193,9 +210,7 @@ Get the minimum elapsed time between reports.
193210)pbdoc" );
194211 thing.def (
195212 " start_time" ,
196- [](Reporter const & self) -> std::chrono::system_clock::time_point {
197- return self.start_time ();
198- },
213+ [](Reporter const & self) { return to_system (self.start_time ()); },
199214 R"pbdoc(
200215Get the start time.
201216
@@ -250,7 +265,7 @@ Reset the start time (and last report) to now.
250265 warn(message, DeprecationWarning, level)
251266 )" );
252267
253- return self.last_report ();
268+ return to_system ( self.last_report () );
254269 },
255270 R"pbdoc(
256271Get the time point of the last report. This function returns the time point of the
You can’t perform that action at this time.
0 commit comments