mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 10:03:50 +01:00
ztimer/overhead: acquire and release clocks
The start/stop overhead that might by introduced by ztimer_acquire() and ztimer_release() called during ztimer_set() resp. ztimer_handler() should not be mesured here. It has its own adjustment field. Furthermore, the overhead mesaurement uses ztimer_now(). It is allowed to called it only after the clock has been acquired.
This commit is contained in:
parent
88a9f4b8f9
commit
bf5dd34deb
@ -43,18 +43,21 @@ int32_t ztimer_overhead_set(ztimer_clock_t *clock, uint32_t base)
|
|||||||
callback_arg_t arg = { .clock = clock, .val = &after };
|
callback_arg_t arg = { .clock = clock, .val = &after };
|
||||||
ztimer_t t = { .callback = _callback, .arg = &arg };
|
ztimer_t t = { .callback = _callback, .arg = &arg };
|
||||||
|
|
||||||
|
ztimer_acquire(clock);
|
||||||
pre = ztimer_now(clock);
|
pre = ztimer_now(clock);
|
||||||
ztimer_set(clock, &t, base);
|
ztimer_set(clock, &t, base);
|
||||||
while (!after) {}
|
while (!after) {}
|
||||||
|
ztimer_release(clock);
|
||||||
return after - pre - base;
|
return after - pre - base;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ztimer_overhead_sleep(ztimer_clock_t *clock, uint32_t base)
|
int32_t ztimer_overhead_sleep(ztimer_clock_t *clock, uint32_t base)
|
||||||
{
|
{
|
||||||
|
ztimer_acquire(clock);
|
||||||
uint32_t pre = ztimer_now(clock);
|
uint32_t pre = ztimer_now(clock);
|
||||||
|
|
||||||
ztimer_sleep(clock, base);
|
ztimer_sleep(clock, base);
|
||||||
uint32_t after = ztimer_now(clock);
|
uint32_t after = ztimer_now(clock);
|
||||||
|
ztimer_release(clock);
|
||||||
|
|
||||||
return after - pre - base;
|
return after - pre - base;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user