memilio icon indicating copy to clipboard operation
memilio copied to clipboard

Time measurement

Open elisabeth96 opened this issue 3 years ago • 8 comments

In order to better detect bottlenecks or time consuming code parts, time measurement should be enabled / integrated. The question remains how we would like to do this. A simple option would be via OpenMP but this would be that it gets deactivated once the project is not build with OpenMP by a user.

Any better suggestions @dabele @joergbrech ?

(Text added by @mknaranja)

elisabeth96 avatar Aug 25 '21 07:08 elisabeth96

please add a description to what should be done/discussed.

dabele avatar Sep 22 '21 13:09 dabele

Hey team! Please add your planning poker estimate with ZenHub @dabele @elisabeth96 @joergbrech @reneSchm @mknaranja

mknaranja avatar Oct 06 '21 09:10 mknaranja

I think this still needs refinement before we can estimate it.

The use case is not clear to me. Should it be just a simple stopwatch that can you can add to the code on demand during development, then immediately print the time? Or should it be something that is more advanced? Should it be able to collect multiple measurements and print at the end? Should it support scopes, similar to a profiler? should it be integrated with the logging system or is printing always ad-hoc using whatever way works for debugging? Should it be part of the code constantly, like logging, but deactivateable?

dabele avatar Oct 06 '21 11:10 dabele

Would it make sense to add Google Benchmarks to our CMake Project, sort of like our unit tests?

joergbrech avatar Oct 06 '21 12:10 joergbrech

I think that's another issue. We maybe want to have benchmarks in the future, but I also would like to offer time measurements in normal code execution (like examples), don't you?

mknaranja avatar Oct 06 '21 12:10 mknaranja

Generally, we should run our algorithms many times in benchmark situations, in particular as for most algorithms execution time is small!

For further discussion, here is some nice short summary on this topic as first answer: https://stackoverflow.com/questions/20586661/what-should-i-check-cpu-time-or-wall-time or https://service.futurequest.net/index.php?/Knowledgebase/Article/View/407/0/difference-between-cpu-time-and-wall-time

Some notes on plain C++ time measurement:

https://www.geeksforgeeks.org/measure-execution-time-function-cpp/ https://iq.opengenus.org/measure-time-in-cpp/

  • The high_resolution_clock is not implemented consistently across different standard library implementations, and its use should be avoided
  • Class std::chrono::steady_clock represents a monotonic clock. The time points of this clock cannot decrease as physical time moves forward and the time between ticks of this clock is constant. This clock is not related to wall clock time (https://en.cppreference.com/w/cpp/chrono/steady_clock)
  • Class std::chrono::system_clock represents the system-wide real time wall clock. It may not be monotonic: on most systems, the system time can be adjusted at any moment. It is the only C++ clock that has the ability to map its time points to C-style time. (https://en.cppreference.com/w/cpp/chrono/system_clock)

For measuring wall-clock time with OpenMP:

https://www.openmp.org/spec-html/5.0/openmpsu160.html

mknaranja avatar Nov 27 '22 16:11 mknaranja

Closed by #756

dabele avatar Nov 28 '23 10:11 dabele

@dabele I am reopening the issue as (at least after some iterations) understood the issue as more general, i.e., to implement a timing scheme for all models that can be activated/deactivated or changed in granularity for all simulations.

mknaranja avatar Nov 28 '23 10:11 mknaranja