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>
116 lines
3.2 KiB
C
116 lines
3.2 KiB
C
/* msgq_b.c */
|
|
|
|
/*
|
|
* Copyright (c) 1997-2010, 2013-2014 Wind River Systems, Inc.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include "master.h"
|
|
|
|
/**
|
|
* @brief Message queue transfer speed test
|
|
*/
|
|
void message_queue_test(void)
|
|
{
|
|
uint32_t et; /* elapsed time */
|
|
int i;
|
|
timing_t start;
|
|
timing_t end;
|
|
|
|
PRINT_STRING(dashline);
|
|
start = timing_timestamp_get();
|
|
for (i = 0; i < NR_OF_MSGQ_RUNS; i++) {
|
|
k_msgq_put(&DEMOQX1, data_bench, K_FOREVER);
|
|
}
|
|
end = timing_timestamp_get();
|
|
et = (uint32_t)timing_cycles_get(&start, &end);
|
|
PRINT_F(FORMAT, "enqueue 1 byte 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(&DEMOQX1, data_bench, K_FOREVER);
|
|
}
|
|
end = timing_timestamp_get();
|
|
et = (uint32_t)timing_cycles_get(&start, &end);
|
|
|
|
PRINT_F(FORMAT, "dequeue 1 byte msg from 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(&DEMOQX4, data_bench, K_FOREVER);
|
|
}
|
|
end = timing_timestamp_get();
|
|
et = (uint32_t)timing_cycles_get(&start, &end);
|
|
|
|
PRINT_F(FORMAT, "enqueue 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_get(&DEMOQX4, data_bench, K_FOREVER);
|
|
}
|
|
end = timing_timestamp_get();
|
|
et = (uint32_t)timing_cycles_get(&start, &end);
|
|
|
|
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();
|
|
for (i = 0; i < NR_OF_MSGQ_RUNS; i++) {
|
|
k_msgq_put(&DEMOQX1, data_bench, K_FOREVER);
|
|
}
|
|
end = timing_timestamp_get();
|
|
et = (uint32_t)timing_cycles_get(&start, &end);
|
|
|
|
PRINT_F(FORMAT,
|
|
"enqueue 1 byte msg 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(&DEMOQX4, data_bench, K_FOREVER);
|
|
}
|
|
end = timing_timestamp_get();
|
|
et = (uint32_t)timing_cycles_get(&start, &end);
|
|
|
|
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));
|
|
}
|