1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

tests/ps_schedstatistics: Generate load using ztimer

This commit is contained in:
Koen Zandberg 2021-11-16 15:50:48 +01:00
parent 4b95459483
commit 7015392170
No known key found for this signature in database
GPG Key ID: BA1718B37D79F51C
2 changed files with 8 additions and 5 deletions

View File

@ -5,6 +5,8 @@ USEMODULE += shell_commands
USEMODULE += ps USEMODULE += ps
USEMODULE += schedstatistics USEMODULE += schedstatistics
USEMODULE += printf_float USEMODULE += printf_float
USEMODULE += ztimer_usec
USEMODULE += ztimer_sec
# For this test we don't want to use the shell version of # For this test we don't want to use the shell version of
# test_utils_interactive_sync, since we want to synchronize before # test_utils_interactive_sync, since we want to synchronize before

View File

@ -25,7 +25,7 @@
#include <shell.h> #include <shell.h>
#include <thread.h> #include <thread.h>
#include <xtimer.h> #include <ztimer.h>
#include "test_utils/interactive_sync.h" #include "test_utils/interactive_sync.h"
@ -44,10 +44,11 @@ static void *_thread_fn(void *arg)
msg_t m1, m2; msg_t m1, m2;
msg_receive(&m1); msg_receive(&m1);
/* generate different loads per thead */ /* generate different loads per thead */
for (int i = 0; i < (10 * (next + 1)); ++i) { for (int i = 0; i < (100 * (next + 1)); ++i) {
_xtimer_now64(); volatile uint32_t now = ztimer_now(ZTIMER_USEC);
(void)now;
} }
xtimer_usleep(XTIMER_BACKOFF * 10); ztimer_sleep(ZTIMER_USEC, 100); /* Sleep for a bit */
msg_send(&m2, pids[next]); msg_send(&m2, pids[next]);
} }
@ -65,7 +66,7 @@ int main(void)
_thread_fn, (void *)i, "thread"); _thread_fn, (void *)i, "thread");
} }
/* sleep for a second, so that `ps` shows some % on idle at the beginning */ /* sleep for a second, so that `ps` shows some % on idle at the beginning */
xtimer_sleep(1); ztimer_sleep(ZTIMER_SEC, 1);
msg_t msg; msg_t msg;
msg_send(&msg, pids[0]); msg_send(&msg, pids[0]);