mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 20:53:33 +08:00
drv_hrt posix: improve performance for hrt_absolute_time()
Previously hrt_absolute_time() was at around 5% of the total CPU usage, now it's around 0.35%.
This commit is contained in:
@@ -154,6 +154,11 @@ uint64_t hrt_system_time()
|
|||||||
*/
|
*/
|
||||||
hrt_abstime hrt_absolute_time()
|
hrt_abstime hrt_absolute_time()
|
||||||
{
|
{
|
||||||
|
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
|
// optimized case (avoid ts_to_abstime) if lockstep scheduler is used
|
||||||
|
const uint64_t abstime = lockstep_scheduler.get_absolute_time();
|
||||||
|
return abstime - px4_timestart_monotonic;
|
||||||
|
#else // defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
|
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
#ifdef __PX4_QURT
|
#ifdef __PX4_QURT
|
||||||
@@ -161,6 +166,7 @@ hrt_abstime hrt_absolute_time()
|
|||||||
#else
|
#else
|
||||||
return ts_to_abstime(&ts);
|
return ts_to_abstime(&ts);
|
||||||
#endif
|
#endif
|
||||||
|
#endif // defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __PX4_QURT
|
#ifdef __PX4_QURT
|
||||||
|
|||||||
Reference in New Issue
Block a user