[ac7d5ef0] | 1 | /* |
---|
| 2 | * |
---|
| 3 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
| 4 | * On-Line Applications Research Corporation (OAR). |
---|
| 5 | * All rights assigned to U.S. Government, 1994. |
---|
| 6 | * |
---|
| 7 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 8 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 9 | * notice must appear in all copies of this file and its derivatives. |
---|
| 10 | * |
---|
| 11 | * $Id$ |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | |
---|
[3a4ae6c] | 15 | #define TEST_INIT |
---|
[ac7d5ef0] | 16 | #include "system.h" |
---|
| 17 | |
---|
| 18 | #define MAXIMUM_DISTRIBUTION 10000 |
---|
| 19 | |
---|
| 20 | #undef OPERATION_COUNT |
---|
| 21 | #define OPERATION_COUNT 100000 |
---|
| 22 | |
---|
| 23 | int Distribution[ MAXIMUM_DISTRIBUTION + 1 ]; |
---|
| 24 | |
---|
| 25 | rtems_task Task_1( |
---|
| 26 | rtems_task_argument argument |
---|
| 27 | ); |
---|
| 28 | |
---|
| 29 | void check_read_timer( void ); |
---|
| 30 | |
---|
| 31 | rtems_task Init( |
---|
| 32 | rtems_task_argument argument |
---|
| 33 | ) |
---|
| 34 | { |
---|
| 35 | rtems_id id; |
---|
| 36 | rtems_status_code status; |
---|
| 37 | |
---|
| 38 | /* |
---|
| 39 | * Tell the Timer Driver what we are doing |
---|
| 40 | */ |
---|
| 41 | |
---|
| 42 | Set_find_average_overhead( 1 ); |
---|
| 43 | |
---|
[3a4ae6c] | 44 | Print_Warning(); |
---|
| 45 | |
---|
[ac7d5ef0] | 46 | puts( "\n\n*** TIME CHECKER ***" ); |
---|
| 47 | |
---|
| 48 | Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ), |
---|
| 49 | |
---|
| 50 | status = rtems_task_create( |
---|
| 51 | 1, |
---|
| 52 | 5, |
---|
[3652ad35] | 53 | RTEMS_MINIMUM_STACK_SIZE, |
---|
[ac7d5ef0] | 54 | RTEMS_DEFAULT_MODES, |
---|
| 55 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
| 56 | &id |
---|
| 57 | ); |
---|
| 58 | directive_failed( status, "rtems_task_create of TA1" ); |
---|
| 59 | |
---|
| 60 | status = rtems_task_start( id, Task_1, 0 ); |
---|
| 61 | directive_failed( status, "rtems_task_start of TA1" ); |
---|
| 62 | |
---|
| 63 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 64 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | rtems_task Task_1( |
---|
| 68 | rtems_task_argument argument |
---|
| 69 | ) |
---|
| 70 | { |
---|
| 71 | rtems_unsigned32 index; |
---|
| 72 | |
---|
| 73 | check_read_timer(); |
---|
| 74 | pause(); |
---|
| 75 | |
---|
| 76 | Timer_initialize(); |
---|
| 77 | end_time = Read_timer(); |
---|
| 78 | |
---|
| 79 | put_time( |
---|
| 80 | "NULL timer stopped at", |
---|
| 81 | end_time, |
---|
| 82 | 1, |
---|
| 83 | 0, |
---|
| 84 | 0 |
---|
| 85 | ); |
---|
| 86 | |
---|
| 87 | Timer_initialize(); |
---|
| 88 | for ( index = 1 ; index <= 1000 ; index++ ) |
---|
| 89 | (void) Empty_function(); |
---|
| 90 | end_time = Read_timer(); |
---|
| 91 | |
---|
| 92 | put_time( |
---|
| 93 | "LOOP (1000) timer stopped at", |
---|
| 94 | end_time, |
---|
| 95 | 1, |
---|
| 96 | 0, |
---|
| 97 | 0 |
---|
| 98 | ); |
---|
| 99 | |
---|
| 100 | Timer_initialize(); |
---|
| 101 | for ( index = 1 ; index <= 10000 ; index++ ) |
---|
| 102 | (void) Empty_function(); |
---|
| 103 | end_time = Read_timer(); |
---|
| 104 | |
---|
| 105 | put_time( |
---|
| 106 | "LOOP (10000) timer stopped at", |
---|
| 107 | end_time, |
---|
| 108 | 1, |
---|
| 109 | 0, |
---|
| 110 | 0 |
---|
| 111 | ); |
---|
| 112 | |
---|
| 113 | Timer_initialize(); |
---|
| 114 | for ( index = 1 ; index <= 50000 ; index++ ) |
---|
| 115 | (void) Empty_function(); |
---|
| 116 | end_time = Read_timer(); |
---|
| 117 | |
---|
| 118 | put_time( |
---|
| 119 | "LOOP (50000) timer stopped at", |
---|
| 120 | end_time, |
---|
| 121 | 1, |
---|
| 122 | 0, |
---|
| 123 | 0 |
---|
| 124 | ); |
---|
| 125 | |
---|
| 126 | Timer_initialize(); |
---|
| 127 | for ( index = 1 ; index <= 100000 ; index++ ) |
---|
| 128 | (void) Empty_function(); |
---|
| 129 | end_time = Read_timer(); |
---|
| 130 | |
---|
| 131 | put_time( |
---|
| 132 | "LOOP (100000) timer stopped at", |
---|
| 133 | end_time, |
---|
| 134 | 1, |
---|
| 135 | 0, |
---|
| 136 | 0 |
---|
| 137 | ); |
---|
| 138 | |
---|
[3a4ae6c] | 139 | puts( "*** END OF TIME CHECKER ***" ); |
---|
[ac7d5ef0] | 140 | exit( 0 ); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | void check_read_timer() |
---|
| 144 | { |
---|
| 145 | rtems_unsigned32 index; |
---|
| 146 | rtems_unsigned32 time; |
---|
| 147 | |
---|
| 148 | for ( index = 1 ; index <= MAXIMUM_DISTRIBUTION ; index++ ) |
---|
| 149 | Distribution[ index ] = 0; |
---|
| 150 | |
---|
| 151 | for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
| 152 | Timer_initialize(); |
---|
| 153 | end_time = Read_timer(); |
---|
| 154 | if ( end_time > MAXIMUM_DISTRIBUTION ) { |
---|
| 155 | /* |
---|
| 156 | * Under UNIX a simple process swap takes longer than we |
---|
| 157 | * consider valid for our testing purposes. |
---|
| 158 | */ |
---|
[4ca27cf] | 159 | printf( "TOO LONG (%d) at index %d!!!\n", end_time, index ); |
---|
| 160 | #if defined(unix) || defined(go32) |
---|
[ac7d5ef0] | 161 | index--; |
---|
| 162 | continue; |
---|
| 163 | #else |
---|
| 164 | exit( 1 ); |
---|
| 165 | #endif |
---|
| 166 | } |
---|
| 167 | else |
---|
| 168 | Distribution[ end_time ]++; |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | printf( "Units may not be in microseconds for this test!!!\n" ); |
---|
| 172 | time = 0; |
---|
| 173 | for ( index = 0 ; index <= MAXIMUM_DISTRIBUTION ; index++ ) { |
---|
| 174 | time += (Distribution[ index ] * index); |
---|
| 175 | if ( Distribution[ index ] != 0 ) |
---|
| 176 | printf( "%d %d\n", index, Distribution[ index ] ); |
---|
| 177 | } |
---|
| 178 | printf( "Total time = %d\n", time ); |
---|
| 179 | printf( "Average time = %d\n", time / OPERATION_COUNT ); |
---|
| 180 | } |
---|