1 #include "Client_Task.h"
2 #include "ace/OS_NS_time.h"
4 Client_Task::Client_Task (const ACE_TCHAR
*data_type
,
6 Test::Roundtrip_ptr roundtrip
,
8 : data_type_ (data_type
)
10 , roundtrip_ (Test::Roundtrip::_duplicate (roundtrip
))
11 , niterations_ (niterations
)
20 this->validate_connection ();
22 if (ACE_OS::strcmp (this->data_type_
, ACE_TEXT("octet")) == 0 )
24 this->test_octet_seq ();
26 if (ACE_OS::strcmp (this->data_type_
, ACE_TEXT("long")) == 0 )
28 this->test_long_seq ();
30 if (ACE_OS::strcmp (this->data_type_
, ACE_TEXT("short")) == 0 )
32 this->test_short_seq ();
34 if (ACE_OS::strcmp (this->data_type_
, ACE_TEXT("char")) == 0 )
36 this->test_char_seq ();
38 if (ACE_OS::strcmp (this->data_type_
, ACE_TEXT("longlong")) == 0 )
40 this->test_longlong_seq ();
42 if (ACE_OS::strcmp (this->data_type_
, ACE_TEXT("double")) == 0 )
44 this->test_double_seq ();
47 catch (const CORBA::Exception
&)
55 Client_Task::accumulate_and_dump (
56 ACE_Basic_Stats
&totals
,
58 ACE_High_Res_Timer::global_scale_factor_type gsf
)
60 totals
.accumulate (this->latency_
);
61 this->latency_
.dump_results (msg
, gsf
);
65 Client_Task::validate_connection ()
67 CORBA::ULongLong dummy
= 0;
70 for (int i
= 0; i
!= 100; ++i
)
74 (void) this->roundtrip_
->test_octet_method (oc
, dummy
);
76 catch (const CORBA::Exception
&){}
81 Client_Task::test_octet_seq ()
83 Test::octet_load
ol (this->size_
);
84 ol
.length (this->size_
);
86 for (int i
= 0; i
!= this->niterations_
; ++i
)
88 ACE_hrtime_t start
= ACE_OS::gethrtime ();
90 (void) this->roundtrip_
->test_octet_method (ol
, start
);
92 ACE_hrtime_t now
= ACE_OS::gethrtime ();
93 this->latency_
.sample (now
- start
);
98 Client_Task::test_long_seq ()
100 Test::long_load
ll (this->size_
);
101 ll
.length (this->size_
);
103 for (int i
= 0; i
!= this->niterations_
; ++i
)
105 ACE_hrtime_t start
= ACE_OS::gethrtime ();
107 (void) this->roundtrip_
->test_long_method (ll
, start
);
109 ACE_hrtime_t now
= ACE_OS::gethrtime ();
110 this->latency_
.sample (now
- start
);
116 Client_Task::test_short_seq ()
118 Test::short_load
sl (this->size_
);
119 sl
.length (this->size_
);
121 for (int i
= 0; i
!= this->niterations_
; ++i
)
123 ACE_hrtime_t start
= ACE_OS::gethrtime ();
125 (void) this->roundtrip_
->test_short_method (sl
, start
);
127 ACE_hrtime_t now
= ACE_OS::gethrtime ();
128 this->latency_
.sample (now
- start
);
133 Client_Task::test_char_seq ()
135 Test::char_load
cl (this->size_
);
136 cl
.length (this->size_
);
138 for (int i
= 0; i
!= this->niterations_
; ++i
)
140 ACE_hrtime_t start
= ACE_OS::gethrtime ();
142 (void) this->roundtrip_
->test_char_method (cl
, start
);
144 ACE_hrtime_t now
= ACE_OS::gethrtime ();
145 this->latency_
.sample (now
- start
);
150 Client_Task::test_longlong_seq ()
152 Test::longlong_load
ll (this->size_
);
153 ll
.length (this->size_
);
155 for (int i
= 0; i
!= this->niterations_
; ++i
)
157 ACE_hrtime_t start
= ACE_OS::gethrtime ();
159 (void) this->roundtrip_
->test_longlong_method (ll
, start
);
161 ACE_hrtime_t now
= ACE_OS::gethrtime ();
162 this->latency_
.sample (now
- start
);
167 Client_Task::test_double_seq ()
169 Test::double_load
dl (this->size_
);
170 dl
.length (this->size_
);
172 for (int i
= 0; i
!= this->niterations_
; ++i
)
174 ACE_hrtime_t start
= ACE_OS::gethrtime ();
176 (void) this->roundtrip_
->test_double_method (dl
, start
);
178 ACE_hrtime_t now
= ACE_OS::gethrtime ();
179 this->latency_
.sample (now
- start
);