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 | |
---|
15 | #include "system.h" |
---|
16 | #undef EXTERN |
---|
17 | #define EXTERN |
---|
18 | #include "conftbl.h" |
---|
19 | #include "gvar.h" |
---|
20 | |
---|
21 | #define MAXIMUM_DISTRIBUTION 10000 |
---|
22 | |
---|
23 | #undef OPERATION_COUNT |
---|
24 | #define OPERATION_COUNT 100000 |
---|
25 | |
---|
26 | int Distribution[ MAXIMUM_DISTRIBUTION + 1 ]; |
---|
27 | |
---|
28 | rtems_task Task_1( |
---|
29 | rtems_task_argument argument |
---|
30 | ); |
---|
31 | |
---|
32 | void check_read_timer( void ); |
---|
33 | |
---|
34 | rtems_task Init( |
---|
35 | rtems_task_argument argument |
---|
36 | ) |
---|
37 | { |
---|
38 | rtems_id id; |
---|
39 | rtems_status_code status; |
---|
40 | |
---|
41 | /* |
---|
42 | * Tell the Timer Driver what we are doing |
---|
43 | */ |
---|
44 | |
---|
45 | Set_find_average_overhead( 1 ); |
---|
46 | |
---|
47 | puts( "\n\n*** TIME CHECKER ***" ); |
---|
48 | |
---|
49 | Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' ), |
---|
50 | |
---|
51 | status = rtems_task_create( |
---|
52 | 1, |
---|
53 | 5, |
---|
54 | 1024, |
---|
55 | RTEMS_DEFAULT_MODES, |
---|
56 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
57 | &id |
---|
58 | ); |
---|
59 | directive_failed( status, "rtems_task_create of TA1" ); |
---|
60 | |
---|
61 | status = rtems_task_start( id, Task_1, 0 ); |
---|
62 | directive_failed( status, "rtems_task_start of TA1" ); |
---|
63 | |
---|
64 | status = rtems_task_delete( RTEMS_SELF ); |
---|
65 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
66 | } |
---|
67 | |
---|
68 | rtems_task Task_1( |
---|
69 | rtems_task_argument argument |
---|
70 | ) |
---|
71 | { |
---|
72 | rtems_unsigned32 index; |
---|
73 | |
---|
74 | check_read_timer(); |
---|
75 | pause(); |
---|
76 | |
---|
77 | Timer_initialize(); |
---|
78 | end_time = Read_timer(); |
---|
79 | |
---|
80 | put_time( |
---|
81 | "NULL timer stopped at", |
---|
82 | end_time, |
---|
83 | 1, |
---|
84 | 0, |
---|
85 | 0 |
---|
86 | ); |
---|
87 | |
---|
88 | Timer_initialize(); |
---|
89 | for ( index = 1 ; index <= 1000 ; index++ ) |
---|
90 | (void) Empty_function(); |
---|
91 | end_time = Read_timer(); |
---|
92 | |
---|
93 | put_time( |
---|
94 | "LOOP (1000) timer stopped at", |
---|
95 | end_time, |
---|
96 | 1, |
---|
97 | 0, |
---|
98 | 0 |
---|
99 | ); |
---|
100 | |
---|
101 | Timer_initialize(); |
---|
102 | for ( index = 1 ; index <= 10000 ; index++ ) |
---|
103 | (void) Empty_function(); |
---|
104 | end_time = Read_timer(); |
---|
105 | |
---|
106 | put_time( |
---|
107 | "LOOP (10000) timer stopped at", |
---|
108 | end_time, |
---|
109 | 1, |
---|
110 | 0, |
---|
111 | 0 |
---|
112 | ); |
---|
113 | |
---|
114 | Timer_initialize(); |
---|
115 | for ( index = 1 ; index <= 50000 ; index++ ) |
---|
116 | (void) Empty_function(); |
---|
117 | end_time = Read_timer(); |
---|
118 | |
---|
119 | put_time( |
---|
120 | "LOOP (50000) timer stopped at", |
---|
121 | end_time, |
---|
122 | 1, |
---|
123 | 0, |
---|
124 | 0 |
---|
125 | ); |
---|
126 | |
---|
127 | Timer_initialize(); |
---|
128 | for ( index = 1 ; index <= 100000 ; index++ ) |
---|
129 | (void) Empty_function(); |
---|
130 | end_time = Read_timer(); |
---|
131 | |
---|
132 | put_time( |
---|
133 | "LOOP (100000) timer stopped at", |
---|
134 | end_time, |
---|
135 | 1, |
---|
136 | 0, |
---|
137 | 0 |
---|
138 | ); |
---|
139 | |
---|
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 | */ |
---|
159 | printf( "TOO LONG (%d) at index %d!!!\n", end_time, index ); |
---|
160 | #if defined(unix) || defined(go32) |
---|
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 | } |
---|