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 #if !defined(MAXIMUM_DISTRIBUTION)
0043 #define MAXIMUM_DISTRIBUTION 1000
0044 #endif
0045
0046 const char rtems_test_name[] = "TIME CHECKER";
0047
0048 uint32_t Distribution[ MAXIMUM_DISTRIBUTION + 1 ];
0049
0050 rtems_task Task_1(
0051 rtems_task_argument argument
0052 );
0053
0054 void check_read_timer( void );
0055
0056 rtems_task Init(
0057 rtems_task_argument argument
0058 )
0059 {
0060 rtems_id id;
0061 rtems_status_code status;
0062
0063
0064
0065
0066
0067 benchmark_timer_disable_subtracting_average_overhead( 1 );
0068
0069 Print_Warning();
0070
0071 TEST_BEGIN();
0072
0073 Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ),
0074
0075 status = rtems_task_create(
0076 1,
0077 5,
0078 RTEMS_MINIMUM_STACK_SIZE,
0079 RTEMS_DEFAULT_MODES,
0080 RTEMS_DEFAULT_ATTRIBUTES,
0081 &id
0082 );
0083 directive_failed( status, "rtems_task_create of TA1" );
0084
0085 status = rtems_task_start( id, Task_1, 0 );
0086 directive_failed( status, "rtems_task_start of TA1" );
0087
0088 rtems_task_exit();
0089 }
0090
0091 rtems_task Task_1(
0092 rtems_task_argument argument
0093 )
0094 {
0095 uint32_t index;
0096
0097 check_read_timer();
0098
0099 benchmark_timer_initialize();
0100 end_time = benchmark_timer_read();
0101
0102 put_time(
0103 "Time Check: NULL timer stopped at",
0104 end_time,
0105 1,
0106 0,
0107 0
0108 );
0109
0110 benchmark_timer_initialize();
0111 for ( index = 1 ; index <= 1000 ; index++ )
0112 (void) benchmark_timer_empty_function();
0113 end_time = benchmark_timer_read();
0114
0115 put_time(
0116 "Time Check: LOOP (1000) timer stopped at",
0117 end_time,
0118 1,
0119 0,
0120 0
0121 );
0122
0123 benchmark_timer_initialize();
0124 for ( index = 1 ; index <= 10000 ; index++ )
0125 (void) benchmark_timer_empty_function();
0126 end_time = benchmark_timer_read();
0127
0128 put_time(
0129 "Time Check: LOOP (10000) timer stopped at",
0130 end_time,
0131 1,
0132 0,
0133 0
0134 );
0135
0136 benchmark_timer_initialize();
0137 for ( index = 1 ; index <= 50000 ; index++ )
0138 (void) benchmark_timer_empty_function();
0139 end_time = benchmark_timer_read();
0140
0141 put_time(
0142 "Time Check: LOOP (50000) timer stopped at",
0143 end_time,
0144 1,
0145 0,
0146 0
0147 );
0148
0149 benchmark_timer_initialize();
0150 for ( index = 1 ; index <= 100000 ; index++ )
0151 (void) benchmark_timer_empty_function();
0152 end_time = benchmark_timer_read();
0153
0154 put_time(
0155 "Time Check: LOOP (100000) timer stopped at",
0156 end_time,
0157 1,
0158 0,
0159 0
0160 );
0161
0162 TEST_END();
0163 rtems_test_exit( 0 );
0164 }
0165
0166 void check_read_timer()
0167 {
0168 uint32_t index;
0169 uint32_t time;
0170
0171 for ( index = 1 ; index <= MAXIMUM_DISTRIBUTION ; index++ )
0172 Distribution[ index ] = 0;
0173
0174 for ( index = 1 ; index <= OPERATION_COUNT ; ) {
0175 benchmark_timer_initialize();
0176 end_time = benchmark_timer_read();
0177 if ( end_time > MAXIMUM_DISTRIBUTION ) {
0178
0179
0180
0181
0182 printf( "TOO LONG (%" PRIu32 ") at index %" PRIu32 "!!!\n", end_time, index );
0183 continue;
0184 }
0185 Distribution[ end_time ]++;
0186 index++;
0187 }
0188
0189 printf( "Units may not be in microseconds for this test!!!\n" );
0190 time = 0;
0191 for ( index = 0 ; index <= MAXIMUM_DISTRIBUTION ; index++ ) {
0192 time += (Distribution[ index ] * index);
0193 if ( Distribution[ index ] != 0 )
0194 printf( "%" PRId32 " %" PRId32 "\n", index, Distribution[ index ] );
0195 }
0196 printf( "Total time = %" PRId32 "\n", time );
0197 printf( "Average time = %" PRId32 "\n", time / OPERATION_COUNT );
0198 }