Skip to content
Snippets Groups Projects
Commit faa66d48 authored by Christoph Pohl's avatar Christoph Pohl Committed by ARMAR-DE
Browse files

Improve realtime capabilities of armarx::rtNow()

Signed-off-by: ARMAR-DE <>
parent 30cb13e8
No related branches found
No related tags found
No related merge requests found
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
namespace armarx namespace armarx
{ {
inline IceUtil::Time inline IceUtil::Time
rtNow() rtNow()
{ {
return IceUtil::Time::now(IceUtil::Time::Monotonic); struct timespec ts;
// using namespace std::chrono; clock_gettime(CLOCK_MONOTONIC, &ts);
// auto epoch = time_point_cast<microseconds>(high_resolution_clock::now()).time_since_epoch(); return IceUtil::Time::microSeconds(ts.tv_sec * 1e6 + ts.tv_nsec / 1000);
// return IceUtil::Time::microSeconds(duration_cast<milliseconds>(epoch).count());
} }
} // namespace armarx } // namespace armarx
...@@ -43,9 +43,8 @@ namespace armarx ...@@ -43,9 +43,8 @@ namespace armarx
//! \ingroup VirtualTime //! \ingroup VirtualTime
//! Prints duration with comment in front of it, yet only once per second. //! Prints duration with comment in front of it, yet only once per second.
#define RT_TIMING_END_COMMENT(name, comment) \ #define RT_TIMING_END_COMMENT(name, comment) \
ARMARX_RT_LOGF_INFO("%s - duration: %.3f ms", \ ARMARX_RT_LOGF_INFO( \
comment, \ "%s - duration: %.3f ms", comment, (armarx::rtNow() - name).toMilliSecondsDouble()) \
IceUtil::Time(armarx::rtNow() - name).toMilliSecondsDouble()) \
.deactivateSpam(1); .deactivateSpam(1);
//! \ingroup VirtualTime //! \ingroup VirtualTime
//! Prints duration //! Prints duration
...@@ -53,7 +52,7 @@ namespace armarx ...@@ -53,7 +52,7 @@ namespace armarx
//! \ingroup VirtualTime //! \ingroup VirtualTime
//! Prints duration with comment in front of it if it took longer than threshold //! Prints duration with comment in front of it if it took longer than threshold
#define RT_TIMING_CEND_COMMENT(name, comment, thresholdMs) \ #define RT_TIMING_CEND_COMMENT(name, comment, thresholdMs) \
if ((armarx::rtNow() - name).toMilliSecondsDouble() >= thresholdMs) \ if ((armarx::rtNow() - name).toMicroSeconds() >= thresholdMs) \
RT_TIMING_END_COMMENT(name, comment) RT_TIMING_END_COMMENT(name, comment)
//! \ingroup VirtualTime //! \ingroup VirtualTime
//! Prints duration if it took longer than thresholdMs //! Prints duration if it took longer than thresholdMs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment