1 #include "tao/DynamicInterface/Request.h"
2 #include "tao/Strategies/advanced_resource.h"
3 #include "tao/AnyTypeCode/TypeCode_Constants.h"
4 #include "tao/AnyTypeCode/Any.h"
6 #include "ace/Get_Opt.h"
7 #include "ace/High_Res_Timer.h"
8 #include "ace/Sched_Params.h"
10 #include "ace/Throughput_Stats.h"
11 #include "ace/Sample_History.h"
12 #include "ace/OS_NS_errno.h"
14 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
15 int niterations
= 100;
16 int do_dump_history
= 0;
20 parse_args (int argc
, ACE_TCHAR
*argv
[])
22 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("hxk:i:"));
25 while ((c
= get_opts ()) != -1)
37 ior
= get_opts
.opt_arg ();
41 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
46 ACE_ERROR_RETURN ((LM_ERROR
,
50 "-x (disable shutdown) "
55 // Indicates successful parsing of the command line
60 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
63 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
64 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
65 // Enable FIFO scheduling
66 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
68 ACE_SCOPE_PROCESS
)) != 0)
70 if (ACE_OS::last_error () == EPERM
)
73 "client (%P|%t): user is not superuser, "
74 "test runs in time-shared class\n"));
78 "client (%P|%t): sched_params failed\n"));
84 CORBA::ORB_init (argc
, argv
);
86 if (parse_args (argc
, argv
) != 0)
89 CORBA::Object_var object
=
90 orb
->string_to_object (ior
);
92 if (CORBA::is_nil (object
.in ()))
94 ACE_ERROR_RETURN ((LM_ERROR
,
95 "Nil CORBA::Object reference <%s>\n",
100 for (int j
= 0; j
< 100; ++j
)
102 CORBA::Request_var request
=
103 object
->_request ("test_method");
105 CORBA::ULongLong dummy
= 0;
106 request
->add_in_arg("send_time") <<= dummy
;
108 request
->set_return_type (CORBA::_tc_ulonglong
);
112 ACE_Sample_History
history (niterations
);
114 ACE_hrtime_t test_start
= ACE_OS::gethrtime ();
115 for (int i
= 0; i
< niterations
; ++i
)
117 ACE_hrtime_t start
= ACE_OS::gethrtime ();
119 CORBA::Request_var request
=
120 object
->_request ("test_method");
122 CORBA::ULongLong start_time
= static_cast <CORBA::ULongLong
> (start
);
123 request
->add_in_arg("send_time") <<= start_time
;
125 request
->set_return_type (CORBA::_tc_ulonglong
);
128 ACE_hrtime_t now
= ACE_OS::gethrtime ();
129 history
.sample (now
- start
);
132 ACE_hrtime_t test_end
= ACE_OS::gethrtime ();
134 ACE_DEBUG ((LM_DEBUG
, "test finished\n"));
136 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
137 ACE_High_Res_Timer::global_scale_factor_type gsf
=
138 ACE_High_Res_Timer::global_scale_factor ();
139 ACE_DEBUG ((LM_DEBUG
, "done\n"));
143 history
.dump_samples (ACE_TEXT("HISTORY"), gsf
);
146 ACE_Basic_Stats stats
;
147 history
.collect_basic_stats (stats
);
148 stats
.dump_results (ACE_TEXT("Total"), gsf
);
150 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
151 test_end
- test_start
,
152 stats
.samples_count ());
156 CORBA::Request_var request
=
157 object
->_request ("shutdown");
162 catch (const CORBA::Exception
& ex
)
164 ex
._tao_print_exception ("Exception caught:");