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, e.g., RT scheduling class on Solaris.
67 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
69 ACE_SCOPE_PROCESS
)) != 0)
71 if (ACE_OS::last_error () == EPERM
)
74 "client (%P|%t): user is not superuser, "
75 "test runs in time-shared class\n"));
79 "client (%P|%t): sched_params failed\n"));
85 CORBA::ORB_init (argc
, argv
);
87 if (parse_args (argc
, argv
) != 0)
90 CORBA::Object_var object
=
91 orb
->string_to_object (ior
);
93 if (CORBA::is_nil (object
.in ()))
95 ACE_ERROR_RETURN ((LM_ERROR
,
96 "Nil CORBA::Object reference <%s>\n",
101 for (int j
= 0; j
< 100; ++j
)
103 CORBA::Request_var request
=
104 object
->_request ("test_method");
106 CORBA::ULongLong dummy
= 0;
107 request
->add_in_arg("send_time") <<= dummy
;
109 request
->set_return_type (CORBA::_tc_ulonglong
);
113 ACE_Sample_History
history (niterations
);
115 ACE_hrtime_t test_start
= ACE_OS::gethrtime ();
116 for (int i
= 0; i
< niterations
; ++i
)
118 ACE_hrtime_t start
= ACE_OS::gethrtime ();
120 CORBA::Request_var request
=
121 object
->_request ("test_method");
123 CORBA::ULongLong start_time
= static_cast <CORBA::ULongLong
> (start
);
124 request
->add_in_arg("send_time") <<= start_time
;
126 request
->set_return_type (CORBA::_tc_ulonglong
);
129 ACE_hrtime_t now
= ACE_OS::gethrtime ();
130 history
.sample (now
- start
);
133 ACE_hrtime_t test_end
= ACE_OS::gethrtime ();
135 ACE_DEBUG ((LM_DEBUG
, "test finished\n"));
137 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
138 ACE_High_Res_Timer::global_scale_factor_type gsf
=
139 ACE_High_Res_Timer::global_scale_factor ();
140 ACE_DEBUG ((LM_DEBUG
, "done\n"));
144 history
.dump_samples (ACE_TEXT("HISTORY"), gsf
);
147 ACE_Basic_Stats stats
;
148 history
.collect_basic_stats (stats
);
149 stats
.dump_results (ACE_TEXT("Total"), gsf
);
151 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
152 test_end
- test_start
,
153 stats
.samples_count ());
157 CORBA::Request_var request
=
158 object
->_request ("shutdown");
164 catch (const CORBA::Exception
& ex
)
166 ex
._tao_print_exception ("Exception caught:");