Bench: opt-in nRF52 instrument for MCU awake time and CPU time per received packet

Changelog: -
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-11-30 12:30:27 +01:00
1 parent d5cbb5ef00
commit ca5e99418b
4 files changed
+85 -1

No files matched your search

+17
View File
@@ -6,6 +6,16 @@
#include <math.h>
#ifdef PWR_DUTY_INSTRUMENT
// CUSTOM (TeTeHacko): bench instrument. Pure CPU time spent processing a received
// packet (dedup + crypto + routing), independent of BLE/USB background wakes --
// unlike the sleep-duty measure. This is the work a radio-side filter could skip
// for a dropped packet. Printed by NRF52Board::sleep() (extern below).
#include <Arduino.h>
uint64_t g_pkt_proc_us = 0;
uint32_t g_pkt_proc_count = 0;
#endif
namespace mesh {
#define MAX_RX_DELAY_MILLIS 32000 // 32 seconds
@@ -273,6 +283,9 @@ void Dispatcher::checkRecv() {
}
void Dispatcher::processRecvPacket(Packet* pkt) {
#ifdef PWR_DUTY_INSTRUMENT
uint32_t _pwr_t0 = micros();
#endif
DispatcherAction action = onRecvPacket(pkt);
if (action == ACTION_RELEASE) {
_mgr->free(pkt);
@@ -284,6 +297,10 @@ void Dispatcher::processRecvPacket(Packet* pkt) {
_mgr->queueOutbound(pkt, priority, futureMillis(_delay));
}
#ifdef PWR_DUTY_INSTRUMENT
g_pkt_proc_us += (uint32_t)(micros() - _pwr_t0);
g_pkt_proc_count++;
#endif
}
void Dispatcher::checkSend() {