-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/event: add event loop debug threshold #21763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
58536de
to
4d884bf
Compare
sys/include/event.h
Outdated
* Use this to prevent *a lot* of output when debugging. | ||
*/ | ||
#ifndef CONFIG_EVENT_LOOP_DEBUG_THRESHOLD | ||
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0) | |
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD_US (0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0) | |
# define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD_US (0) |
Also indentation 👀
sys/include/event.h
Outdated
uint32_t now2 = ztimer_now(ZTIMER_USEC); | ||
uint32_t dt = now2 - now; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint32_t now2 = ztimer_now(ZTIMER_USEC); | |
uint32_t dt = now2 - now; | |
uint32_t dt = ztimer_now(ZTIMER_USEC) - now; |
sys/include/event.h
Outdated
|
||
if ((CONFIG_EVENT_LOOP_DEBUG_THRESHOLD == 0) || | ||
dt > CONFIG_EVENT_LOOP_DEBUG_THRESHOLD) { | ||
printf("eventh: %p took %" PRIu32 " µs\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printf("eventh: %p took %" PRIu32 " µs\n", | |
printf("event: %p took %" PRIu32 " µs\n", |
Typo.
Also I'm not sure if using the actual Mu sign is a good idea, it may not work with some terminal programs. It's probably safer to use us
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing the mu -> u
the h was because i changed fro event to handler being printed
how about:
'event: %p handler: %p queue: %p took:" PRIu32 "usec\n'
sys/include/event.h
Outdated
* Use this to prevent *a lot* of output when debugging. | ||
*/ | ||
#ifndef CONFIG_EVENT_LOOP_DEBUG_THRESHOLD | ||
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0) | |
# define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD_US (0) |
Also indentation 👀
sys/include/event.h
Outdated
* @brief Threshold (USEC) below which event_handler are not printed, | ||
* while debugging eventloop setting a value (!0) will also remove | ||
* event_handler start message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @brief Threshold (USEC) below which event_handler are not printed, | |
* while debugging eventloop setting a value (!0) will also remove | |
* event_handler start message | |
* @brief Threshold in microseconds below which event_handler | |
* are not printed. | |
* | |
* This can be used for debugging event loops. Setting a value | |
* other than zero will also remove the event_handler start message, |
Perhaps a little clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setting a value (!0) will also remove event_handler start message looks easier to read it especially uses less chars to express the case where one should not even set a value ( but rely on the default)
the actual sentence is: setting a value will also remove event_handler start message
<supersmall> other than 0
changed it anyway
sys/include/event.h
Outdated
} | ||
now = ztimer_now(ZTIMER_USEC); | ||
|
||
void * h = event->handler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void * h = event->handler; | |
void *h = event->handler; |
sys/include/event.h
Outdated
if ((CONFIG_EVENT_LOOP_DEBUG_THRESHOLD == 0) || | ||
dt > CONFIG_EVENT_LOOP_DEBUG_THRESHOLD) { | ||
printf("eventh: %p took %" PRIu32 " µs\n", | ||
(void *)h, dt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure why you're casting h
here, it already has the type void *
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i probably first just used event->handler -> needed the cast but then saw the events might change -> h was born
27fd3d7
to
ddfbabb
Compare
ddfbabb
to
79ef710
Compare
79ef710
to
d888d46
Compare
Contribution description
provide a configurable threshold value for printing event handler run time
Testing procedure
Issues/PRs references