1 #include "tao/DynamicInterface/Request.h" /* This must come first for
6 #include "tao/AnyTypeCode/TypeCode_Constants.h"
8 #include "tao/Strategies/advanced_resource.h"
10 #include "ace/Get_Opt.h"
11 #include "ace/Sched_Params.h"
12 #include "ace/High_Res_Timer.h"
13 #include "ace/Sched_Params.h"
14 #include "ace/Stats.h"
15 #include "ace/Throughput_Stats.h"
16 #include "ace/Sample_History.h"
17 #include "ace/OS_NS_errno.h"
19 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
20 int niterations
= 1000;
23 int do_dump_history
= 0;
26 parse_args (int argc
, ACE_TCHAR
*argv
[])
28 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("hxk:i:b:"));
31 while ((c
= get_opts ()) != -1)
43 ior
= get_opts
.opt_arg ();
47 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
51 burst
= ACE_OS::atoi (get_opts
.opt_arg ());
56 ACE_ERROR_RETURN ((LM_ERROR
,
61 "-x (disable shutdown) "
67 // Indicates successful parsing of the command line
72 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
75 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
76 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
77 // Enable FIFO scheduling
79 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
81 ACE_SCOPE_PROCESS
)) != 0)
83 if (ACE_OS::last_error () == EPERM
)
86 "client (%P|%t): user is not superuser, "
87 "test runs in time-shared class\n"));
91 "client (%P|%t): sched_params failed\n"));
97 CORBA::ORB_init (argc
, argv
);
99 if (parse_args (argc
, argv
) != 0)
102 CORBA::Object_var object
=
103 orb
->string_to_object (ior
);
105 Test::Roundtrip_var roundtrip
=
106 Test::Roundtrip::_narrow (object
.in ());
108 if (CORBA::is_nil (roundtrip
.in ()))
110 ACE_ERROR_RETURN ((LM_ERROR
,
111 "Nil Test::Roundtrip reference <%s>\n",
116 for (int j
= 0; j
< 100; ++j
)
118 ACE_hrtime_t start
= 0;
119 (void) roundtrip
->test_method (start
);
122 ACE_Sample_History
history (niterations
);
124 ACE_hrtime_t test_start
= ACE_OS::gethrtime ();
126 CORBA::Request_var
*request
;
127 ACE_NEW_RETURN (request
, CORBA::Request_var
[burst
], 1);
129 for (int i
= 0; i
< niterations
; ++i
)
133 for (j
= 0; j
!= burst
; ++j
)
135 CORBA::ULongLong start
= ACE_OS::gethrtime ();
138 roundtrip
->_request ("test_method");
140 request
[j
]->add_in_arg () <<= start
;
141 request
[j
]->set_return_type (CORBA::_tc_ulonglong
);
143 request
[j
]->send_deferred ();
146 for (j
= 0; j
!= burst
; ++j
)
148 request
[j
]->get_response ();
150 CORBA::ULongLong retval
;
151 if ((request
[j
]->return_value () >>= retval
) == 1)
153 ACE_hrtime_t now
= ACE_OS::gethrtime ();
154 history
.sample (ACE_HRTIME_TO_U64(now
) - retval
);
160 ACE_hrtime_t test_end
= ACE_OS::gethrtime ();
162 ACE_DEBUG ((LM_DEBUG
, "test finished\n"));
164 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
165 ACE_High_Res_Timer::global_scale_factor_type gsf
=
166 ACE_High_Res_Timer::global_scale_factor ();
167 ACE_DEBUG ((LM_DEBUG
, "done\n"));
171 history
.dump_samples (ACE_TEXT("HISTORY"), gsf
);
174 ACE_Basic_Stats stats
;
175 history
.collect_basic_stats (stats
);
176 stats
.dump_results (ACE_TEXT("Total"), gsf
);
178 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
179 test_end
- test_start
,
180 stats
.samples_count ());
184 roundtrip
->shutdown ();
187 catch (const CORBA::Exception
& ex
)
189 ex
._tao_print_exception ("Caught exception:");