diff --git a/src/modules/land_detector/LandDetector.cpp b/src/modules/land_detector/LandDetector.cpp index 3b773c58a2..462dccd9a8 100644 --- a/src/modules/land_detector/LandDetector.cpp +++ b/src/modules/land_detector/LandDetector.cpp @@ -47,11 +47,9 @@ #include #include "uORB/topics/parameter_update.h" - namespace land_detector { - LandDetector::LandDetector() : _landDetectedPub(nullptr), _landDetected{0, false, false}, @@ -63,12 +61,14 @@ LandDetector::LandDetector() : _ground_contact_hysteresis(true), _total_flight_time{0}, _takeoff_time{0}, - _work{} + _work{}, + _cycle_perf(perf_alloc(PC_ELAPSED, "land_detector_cycle")) { } LandDetector::~LandDetector() { + perf_free(_cycle_perf); } int LandDetector::start() @@ -87,6 +87,8 @@ LandDetector::_cycle_trampoline(void *arg) void LandDetector::_cycle() { + perf_begin(_cycle_perf); + if (!_object) { // not initialized yet // Advertise the first land detected uORB. _landDetected.timestamp = hrt_absolute_time(); @@ -155,6 +157,8 @@ void LandDetector::_cycle() &instance, ORB_PRIO_DEFAULT); } + perf_end(_cycle_perf); + if (!should_exit()) { // Schedule next cycle. diff --git a/src/modules/land_detector/LandDetector.h b/src/modules/land_detector/LandDetector.h index 250979eb3a..c65980ac5b 100644 --- a/src/modules/land_detector/LandDetector.h +++ b/src/modules/land_detector/LandDetector.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -175,6 +176,8 @@ private: hrt_abstime _takeoff_time; struct work_s _work; + + perf_counter_t _cycle_perf; };