source: rtems/testsuites/tmtests/tm09/task1.c @ 2ead50a

4.11
Last change on this file since 2ead50a was 2ead50a, checked in by bjorn larsson <bjornlarsson@…>, on Mar 21, 2014 at 3:48:01 PM

tmtests: convert to test.h

  • Property mode set to 100644
File size: 5.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2013.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16
17const char rtems_test_name[] = "TIME TEST 9";
18
19rtems_id Queue_id;
20
21rtems_task Test_task(
22  rtems_task_argument argument
23);
24void queue_test(void);
25
26rtems_task Init(
27  rtems_task_argument argument
28)
29{
30  rtems_status_code status;
31
32  Print_Warning();
33
34  TEST_BEGIN();
35
36  status = rtems_task_create(
37    1,
38    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
39    RTEMS_MINIMUM_STACK_SIZE * 2,
40    RTEMS_DEFAULT_MODES,
41    RTEMS_DEFAULT_ATTRIBUTES,
42    &Task_id[ 1 ]
43  );
44  directive_failed( status, "rtems_task_create" );
45
46  status = rtems_task_start( Task_id[ 1 ], Test_task, 0 );
47  directive_failed( status, "rtems_task_start" );
48
49  status = rtems_task_delete( RTEMS_SELF );
50  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
51}
52
53rtems_task Test_task (
54  rtems_task_argument argument
55)
56{
57  benchmark_timer_initialize();
58    rtems_message_queue_create(
59      1,
60      OPERATION_COUNT,
61      MESSAGE_SIZE,
62      RTEMS_DEFAULT_ATTRIBUTES,
63      &Queue_id
64    );
65  end_time = benchmark_timer_read();
66
67  put_time(
68    "rtems_message_queue_create: only case",
69    end_time,
70    1,
71    0,
72    CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE
73  );
74
75  queue_test();
76
77  benchmark_timer_initialize();
78    rtems_message_queue_delete( Queue_id );
79  end_time = benchmark_timer_read();
80
81  put_time(
82    "rtems_message_queue_delete: only case",
83    end_time,
84    1,
85    0,
86    CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE
87  );
88
89  TEST_END();
90  rtems_test_exit( 0 );
91}
92
93void queue_test(void)
94{
95  uint32_t    send_loop_time;
96  uint32_t    urgent_loop_time;
97  uint32_t    receive_loop_time;
98  uint32_t    send_time;
99  uint32_t    urgent_time;
100  uint32_t    receive_time;
101  uint32_t    empty_flush_time;
102  uint32_t    flush_time;
103  uint32_t    empty_flush_count;
104  uint32_t    flush_count;
105  uint32_t    index;
106  uint32_t    iterations;
107  long        buffer[4];
108  rtems_status_code status;
109  size_t      size;
110
111  send_loop_time    = 0;
112  urgent_loop_time  = 0;
113  receive_loop_time = 0;
114  send_time         = 0;
115  urgent_time       = 0;
116  receive_time      = 0;
117  empty_flush_time  = 0;
118  flush_time        = 0;
119  flush_count       = 0;
120  empty_flush_count = 0;
121
122  for ( iterations = 1 ; iterations <= OPERATION_COUNT ; iterations++ ) {
123
124    benchmark_timer_initialize();
125      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
126        (void) benchmark_timer_empty_function();
127    send_loop_time += benchmark_timer_read();
128
129    benchmark_timer_initialize();
130      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
131        (void) benchmark_timer_empty_function();
132    urgent_loop_time += benchmark_timer_read();
133
134    benchmark_timer_initialize();
135      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
136        (void) benchmark_timer_empty_function();
137    receive_loop_time += benchmark_timer_read();
138
139    benchmark_timer_initialize();
140      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
141        (void) rtems_message_queue_send( Queue_id, buffer, MESSAGE_SIZE );
142    send_time += benchmark_timer_read();
143
144    benchmark_timer_initialize();
145      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
146        (void) rtems_message_queue_receive(
147                 Queue_id,
148                 (long (*)[4])buffer,
149                 &size,
150                 RTEMS_DEFAULT_OPTIONS,
151                 RTEMS_NO_TIMEOUT
152               );
153    receive_time += benchmark_timer_read();
154
155    benchmark_timer_initialize();
156      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
157        (void) rtems_message_queue_urgent( Queue_id, buffer, MESSAGE_SIZE );
158    urgent_time += benchmark_timer_read();
159
160    benchmark_timer_initialize();
161      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
162        (void) rtems_message_queue_receive(
163                 Queue_id,
164                 (long (*)[4])buffer,
165                 &size,
166                 RTEMS_DEFAULT_OPTIONS,
167                 RTEMS_NO_TIMEOUT
168               );
169    receive_time += benchmark_timer_read();
170
171    benchmark_timer_initialize();
172      rtems_message_queue_flush( Queue_id, &empty_flush_count );
173    empty_flush_time += benchmark_timer_read();
174
175    /* send one message to flush */
176    status = rtems_message_queue_send(
177       Queue_id,
178       (long (*)[4])buffer,
179       MESSAGE_SIZE
180    );
181    directive_failed( status, "rtems_message_queue_send" );
182
183    benchmark_timer_initialize();
184      rtems_message_queue_flush( Queue_id, &flush_count );
185    flush_time += benchmark_timer_read();
186  }
187
188  put_time(
189    "rtems_message_queue_send: no waiting tasks",
190    send_time,
191    OPERATION_COUNT * OPERATION_COUNT,
192    send_loop_time,
193    CALLING_OVERHEAD_MESSAGE_QUEUE_SEND
194  );
195
196  put_time(
197    "rtems_message_queue_urgent: no waiting tasks",
198    urgent_time,
199    OPERATION_COUNT * OPERATION_COUNT,
200    urgent_loop_time,
201    CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT
202  );
203
204  put_time(
205    "rtems_message_queue_receive: available",
206    receive_time,
207    OPERATION_COUNT * OPERATION_COUNT * 2,
208    receive_loop_time * 2,
209    CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE
210  );
211
212  put_time(
213    "rtems_message_queue_flush: no messages flushed",
214    empty_flush_time,
215    OPERATION_COUNT,
216    0,
217    CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH
218  );
219
220  put_time(
221    "rtems_message_queue_flush: messages flushed",
222    flush_time,
223    OPERATION_COUNT,
224    0,
225    CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH
226  );
227
228}
Note: See TracBrowser for help on using the repository browser.