File indexing completed on 2025-05-11 08:24:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #if !defined(OPERATION_COUNT)
0030 #define OPERATION_COUNT 100
0031 #endif
0032
0033 #ifdef HAVE_CONFIG_H
0034 #include "config.h"
0035 #endif
0036
0037 #include <rtems/btimer.h>
0038
0039 #define CONFIGURE_INIT
0040 #include "system.h"
0041
0042 const char rtems_test_name[] = "TIME TEST 9";
0043
0044 rtems_id Queue_id;
0045
0046 rtems_task Test_task(
0047 rtems_task_argument argument
0048 );
0049 void queue_test(void);
0050
0051 rtems_task Init(
0052 rtems_task_argument argument
0053 )
0054 {
0055 rtems_status_code status;
0056
0057 Print_Warning();
0058
0059 TEST_BEGIN();
0060
0061 status = rtems_task_create(
0062 1,
0063 (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
0064 RTEMS_MINIMUM_STACK_SIZE * 2,
0065 RTEMS_DEFAULT_MODES,
0066 RTEMS_DEFAULT_ATTRIBUTES,
0067 &Task_id[ 1 ]
0068 );
0069 directive_failed( status, "rtems_task_create" );
0070
0071 status = rtems_task_start( Task_id[ 1 ], Test_task, 0 );
0072 directive_failed( status, "rtems_task_start" );
0073
0074 rtems_task_exit();
0075 }
0076
0077 rtems_task Test_task (
0078 rtems_task_argument argument
0079 )
0080 {
0081 benchmark_timer_initialize();
0082 rtems_message_queue_create(
0083 1,
0084 OPERATION_COUNT,
0085 MESSAGE_SIZE,
0086 RTEMS_DEFAULT_ATTRIBUTES,
0087 &Queue_id
0088 );
0089 end_time = benchmark_timer_read();
0090
0091 put_time(
0092 "rtems_message_queue_create: only case",
0093 end_time,
0094 1,
0095 0,
0096 0
0097 );
0098
0099 queue_test();
0100
0101 benchmark_timer_initialize();
0102 rtems_message_queue_delete( Queue_id );
0103 end_time = benchmark_timer_read();
0104
0105 put_time(
0106 "rtems_message_queue_delete: only case",
0107 end_time,
0108 1,
0109 0,
0110 0
0111 );
0112
0113 TEST_END();
0114 rtems_test_exit( 0 );
0115 }
0116
0117 void queue_test(void)
0118 {
0119 uint32_t send_loop_time;
0120 uint32_t urgent_loop_time;
0121 uint32_t receive_loop_time;
0122 uint32_t send_time;
0123 uint32_t urgent_time;
0124 uint32_t receive_time;
0125 uint32_t empty_flush_time;
0126 uint32_t flush_time;
0127 uint32_t empty_flush_count;
0128 uint32_t flush_count;
0129 uint32_t index;
0130 uint32_t iterations;
0131 long buffer[4];
0132 rtems_status_code status;
0133 size_t size;
0134
0135 send_loop_time = 0;
0136 urgent_loop_time = 0;
0137 receive_loop_time = 0;
0138 send_time = 0;
0139 urgent_time = 0;
0140 receive_time = 0;
0141 empty_flush_time = 0;
0142 flush_time = 0;
0143 flush_count = 0;
0144 empty_flush_count = 0;
0145
0146 for ( iterations = 1 ; iterations <= OPERATION_COUNT ; iterations++ ) {
0147
0148 benchmark_timer_initialize();
0149 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0150 (void) benchmark_timer_empty_function();
0151 send_loop_time += benchmark_timer_read();
0152
0153 benchmark_timer_initialize();
0154 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0155 (void) benchmark_timer_empty_function();
0156 urgent_loop_time += benchmark_timer_read();
0157
0158 benchmark_timer_initialize();
0159 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0160 (void) benchmark_timer_empty_function();
0161 receive_loop_time += benchmark_timer_read();
0162
0163 benchmark_timer_initialize();
0164 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0165 (void) rtems_message_queue_send( Queue_id, buffer, MESSAGE_SIZE );
0166 send_time += benchmark_timer_read();
0167
0168 benchmark_timer_initialize();
0169 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0170 (void) rtems_message_queue_receive(
0171 Queue_id,
0172 (long (*)[4])buffer,
0173 &size,
0174 RTEMS_DEFAULT_OPTIONS,
0175 RTEMS_NO_TIMEOUT
0176 );
0177 receive_time += benchmark_timer_read();
0178
0179 benchmark_timer_initialize();
0180 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0181 (void) rtems_message_queue_urgent( Queue_id, buffer, MESSAGE_SIZE );
0182 urgent_time += benchmark_timer_read();
0183
0184 benchmark_timer_initialize();
0185 for ( index=1 ; index <= OPERATION_COUNT ; index++ )
0186 (void) rtems_message_queue_receive(
0187 Queue_id,
0188 (long (*)[4])buffer,
0189 &size,
0190 RTEMS_DEFAULT_OPTIONS,
0191 RTEMS_NO_TIMEOUT
0192 );
0193 receive_time += benchmark_timer_read();
0194
0195 benchmark_timer_initialize();
0196 rtems_message_queue_flush( Queue_id, &empty_flush_count );
0197 empty_flush_time += benchmark_timer_read();
0198
0199
0200 status = rtems_message_queue_send(
0201 Queue_id,
0202 (long (*)[4])buffer,
0203 MESSAGE_SIZE
0204 );
0205 directive_failed( status, "rtems_message_queue_send" );
0206
0207 benchmark_timer_initialize();
0208 rtems_message_queue_flush( Queue_id, &flush_count );
0209 flush_time += benchmark_timer_read();
0210 }
0211
0212 put_time(
0213 "rtems_message_queue_send: no waiting tasks",
0214 send_time,
0215 OPERATION_COUNT * OPERATION_COUNT,
0216 send_loop_time,
0217 0
0218 );
0219
0220 put_time(
0221 "rtems_message_queue_urgent: no waiting tasks",
0222 urgent_time,
0223 OPERATION_COUNT * OPERATION_COUNT,
0224 urgent_loop_time,
0225 0
0226 );
0227
0228 put_time(
0229 "rtems_message_queue_receive: available",
0230 receive_time,
0231 OPERATION_COUNT * OPERATION_COUNT * 2,
0232 receive_loop_time * 2,
0233 0
0234 );
0235
0236 put_time(
0237 "rtems_message_queue_flush: no messages flushed",
0238 empty_flush_time,
0239 OPERATION_COUNT,
0240 0,
0241 0
0242 );
0243
0244 put_time(
0245 "rtems_message_queue_flush: messages flushed",
0246 flush_time,
0247 OPERATION_COUNT,
0248 0,
0249 0
0250 );
0251
0252 }