1 /* fifo_b.c */
2
3 /*
4 * Copyright (c) 1997-2010, 2013-2014 Wind River Systems, Inc.
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9 #include "master.h"
10
11 #ifdef FIFO_BENCH
12
13 /**
14 *
15 * @brief Queue transfer speed test
16 *
17 */
queue_test(void)18 void queue_test(void)
19 {
20 uint32_t et; /* elapsed time */
21 int i;
22
23 PRINT_STRING(dashline);
24 et = BENCH_START();
25 for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
26 k_msgq_put(&DEMOQX1, data_bench, K_FOREVER);
27 }
28 et = TIME_STAMP_DELTA_GET(et);
29
30 PRINT_F(FORMAT, "enqueue 1 byte msg in FIFO",
31 SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
32
33 et = BENCH_START();
34 for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
35 k_msgq_get(&DEMOQX1, data_bench, K_FOREVER);
36 }
37 et = TIME_STAMP_DELTA_GET(et);
38 check_result();
39
40 PRINT_F(FORMAT, "dequeue 1 byte msg in FIFO",
41 SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
42
43 et = BENCH_START();
44 for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
45 k_msgq_put(&DEMOQX4, data_bench, K_FOREVER);
46 }
47 et = TIME_STAMP_DELTA_GET(et);
48 check_result();
49
50 PRINT_F(FORMAT, "enqueue 4 bytes msg in FIFO",
51 SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
52
53 et = BENCH_START();
54 for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
55 k_msgq_get(&DEMOQX4, data_bench, K_FOREVER);
56 }
57 et = TIME_STAMP_DELTA_GET(et);
58 check_result();
59
60 PRINT_F(FORMAT, "dequeue 4 bytes msg in FIFO",
61 SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
62
63 k_sem_give(&STARTRCV);
64
65 et = BENCH_START();
66 for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
67 k_msgq_put(&DEMOQX1, data_bench, K_FOREVER);
68 }
69 et = TIME_STAMP_DELTA_GET(et);
70 check_result();
71
72 PRINT_F(FORMAT,
73 "enqueue 1 byte msg in FIFO to a waiting higher priority task",
74 SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
75
76 et = BENCH_START();
77 for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
78 k_msgq_put(&DEMOQX4, data_bench, K_FOREVER);
79 }
80 et = TIME_STAMP_DELTA_GET(et);
81 check_result();
82
83 PRINT_F(FORMAT,
84 "enqueue 4 bytes in FIFO to a waiting higher priority task",
85 SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
86 }
87
88 #endif /* FIFO_BENCH */
89