tests: app_kernel: extend msgq test

Extends the msgq benchmark test to obtain data for larger message
queues (messages of size 192 bytes). This allows for a better
indication of what the impact of data size is on message queue
performance.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2023-10-20 11:23:09 -04:00 committed by Carles Cufí
commit 4e426fbfa1
4 changed files with 54 additions and 15 deletions

View file

@ -53,6 +53,7 @@ K_APPMEM_PARTITION_DEFINE(bench_mem_partition);
K_MSGQ_DEFINE(DEMOQX1, 1, 500, 4);
K_MSGQ_DEFINE(DEMOQX4, 4, 500, 4);
K_MSGQ_DEFINE(DEMOQX192, 192, 500, 4);
K_MSGQ_DEFINE(MB_COMM, 12, 1, 4);
K_MSGQ_DEFINE(CH_COMM, 12, 1, 4);
@ -207,9 +208,9 @@ int main(void)
recvtask, (void *)(uintptr_t)true, NULL, NULL,
5, K_USER, K_FOREVER);
k_thread_access_grant(&recv_thread, &DEMOQX1, &DEMOQX4, &MB_COMM,
&CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3, &SEM4,
&STARTRCV, &DEMO_MUTEX,
k_thread_access_grant(&recv_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
&SEM4, &STARTRCV, &DEMO_MUTEX,
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
k_thread_start(&recv_thread);
@ -231,9 +232,9 @@ int main(void)
recvtask, (void *)(uintptr_t)true, NULL, NULL,
5, 0, K_FOREVER);
k_thread_access_grant(&test_thread, &DEMOQX1, &DEMOQX4, &MB_COMM,
&CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3, &SEM4,
&STARTRCV, &DEMO_MUTEX,
k_thread_access_grant(&test_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
&SEM4, &STARTRCV, &DEMO_MUTEX,
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
k_thread_start(&recv_thread);
@ -255,13 +256,13 @@ int main(void)
recvtask, (void *)(uintptr_t)true, NULL, NULL,
5, K_USER, K_FOREVER);
k_thread_access_grant(&test_thread, &DEMOQX1, &DEMOQX4, &MB_COMM,
&CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3, &SEM4,
&STARTRCV, &DEMO_MUTEX,
k_thread_access_grant(&test_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
&SEM4, &STARTRCV, &DEMO_MUTEX,
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
k_thread_access_grant(&recv_thread, &DEMOQX1, &DEMOQX4, &MB_COMM,
&CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3, &SEM4,
&STARTRCV, &DEMO_MUTEX,
k_thread_access_grant(&recv_thread, &DEMOQX1, &DEMOQX4, &DEMOQX192,
&MB_COMM, &CH_COMM, &SEM0, &SEM1, &SEM2, &SEM3,
&SEM4, &STARTRCV, &DEMO_MUTEX,
&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF);
k_thread_start(&recv_thread);

View file

@ -93,6 +93,7 @@ extern struct k_sem STARTRCV;
extern struct k_msgq DEMOQX1;
extern struct k_msgq DEMOQX4;
extern struct k_msgq DEMOQX192;
extern struct k_msgq MB_COMM;
extern struct k_msgq CH_COMM;

View file

@ -58,6 +58,26 @@ void message_queue_test(void)
PRINT_F(FORMAT, "dequeue 4 bytes msg in MSGQ",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_MSGQ_RUNS));
start = timing_timestamp_get();
for (i = 0; i < NR_OF_MSGQ_RUNS; i++) {
k_msgq_put(&DEMOQX192, data_bench, K_FOREVER);
}
end = timing_timestamp_get();
et = (uint32_t)timing_cycles_get(&start, &end);
PRINT_F(FORMAT, "enqueue 192 bytes msg in MSGQ",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_MSGQ_RUNS));
start = timing_timestamp_get();
for (i = 0; i < NR_OF_MSGQ_RUNS; i++) {
k_msgq_get(&DEMOQX192, data_bench, K_FOREVER);
}
end = timing_timestamp_get();
et = (uint32_t)timing_cycles_get(&start, &end);
PRINT_F(FORMAT, "dequeue 192 bytes msg in MSGQ",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_MSGQ_RUNS));
k_sem_give(&STARTRCV);
start = timing_timestamp_get();
@ -81,4 +101,15 @@ void message_queue_test(void)
PRINT_F(FORMAT,
"enqueue 4 bytes in MSGQ to a waiting higher priority task",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_MSGQ_RUNS));
start = timing_timestamp_get();
for (i = 0; i < NR_OF_MSGQ_RUNS; i++) {
k_msgq_put(&DEMOQX192, data_bench, K_FOREVER);
}
end = timing_timestamp_get();
et = (uint32_t)timing_cycles_get(&start, &end);
PRINT_F(FORMAT,
"enqueue 192 bytes in MSGQ to a waiting higher priority task",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_MSGQ_RUNS));
}

View file

@ -11,18 +11,24 @@
/* message queue transfer speed test */
static BENCH_BMEM char buffer[192];
/**
* @brief Data receive task
*/
void dequtask(void)
{
int x, i;
int i;
for (i = 0; i < NR_OF_MSGQ_RUNS; i++) {
k_msgq_get(&DEMOQX1, &x, K_FOREVER);
k_msgq_get(&DEMOQX1, buffer, K_FOREVER);
}
for (i = 0; i < NR_OF_MSGQ_RUNS; i++) {
k_msgq_get(&DEMOQX4, &x, K_FOREVER);
k_msgq_get(&DEMOQX4, buffer, K_FOREVER);
}
for (i = 0; i < NR_OF_MSGQ_RUNS; i++) {
k_msgq_get(&DEMOQX192, buffer, K_FOREVER);
}
}