1
// client.cpp,v 1.3 2003/11/02 23:27:23 dhinton Exp
3
#include "Client_Task.h"
4
#include "ace/Get_Opt.h"
5
#include "ace/High_Res_Timer.h"
6
#include "ace/Sched_Params.h"
8
#include "ace/OS_NS_errno.h"
10
#include "tao/Strategies/advanced_resource.h"
12
ACE_RCSID(Thread_Pool_Latency, client, "client.cpp,v 1.3 2003/11/02 23:27:23 dhinton Exp")
14
const char *ior = "file://test.ior";
15
int niterations = 1000;
19
const char *data_type = "octet";
22
parse_args (int argc, char *argv[])
24
ACE_Get_Opt get_opts (argc, argv, "t:s:xk:i:");
27
while ((c = get_opts ()) != -1)
31
data_type = get_opts.opt_arg ();
33
if (ACE_OS::strcmp (data_type, "octet") != 0 &&
34
ACE_OS::strcmp (data_type, "char") != 0 &&
35
ACE_OS::strcmp (data_type, "long") != 0 &&
36
ACE_OS::strcmp (data_type, "short") != 0 &&
37
ACE_OS::strcmp (data_type, "double") != 0 &&
38
ACE_OS::strcmp (data_type, "longlong") != 0)
43
sz = ACE_OS::atoi (get_opts.opt_arg ());
51
ior = get_opts.opt_arg ();
55
niterations = ACE_OS::atoi (get_opts.opt_arg ());
60
ACE_ERROR_RETURN ((LM_ERROR,
66
"-x (disable shutdown) "
71
// Indicates sucessful parsing of the command line
76
main (int argc, char *argv[])
79
(ACE_Sched_Params::priority_min (ACE_SCHED_FIFO)
80
+ ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2;
81
// Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
83
if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
85
ACE_SCOPE_PROCESS)) != 0)
87
if (ACE_OS::last_error () == EPERM)
90
"client (%P|%t): user is not superuser, "
91
"test runs in time-shared class\n"));
95
"client (%P|%t): sched_params failed\n"));
98
ACE_DECLARE_NEW_CORBA_ENV;
103
CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER);
106
if (parse_args (argc, argv) != 0)
109
CORBA::Object_var object =
110
orb->string_to_object (ior ACE_ENV_ARG_PARAMETER);
113
Test::Roundtrip_var roundtrip =
114
Test::Roundtrip::_narrow (object.in () ACE_ENV_ARG_PARAMETER);
117
if (CORBA::is_nil (roundtrip.in ()))
119
ACE_ERROR_RETURN ((LM_ERROR,
120
"Nil Test::Roundtrip reference <%s>\n",
127
ACE_DEBUG ((LM_DEBUG, "Starting threads\n"));
129
Client_Task task0 (data_type, sz, roundtrip.in (), niterations);
130
Client_Task task1 (data_type, sz, roundtrip.in (), niterations);
131
Client_Task task2 (data_type, sz, roundtrip.in (), niterations);
132
Client_Task task3 (data_type, sz, roundtrip.in (), niterations);
134
ACE_hrtime_t test_start = ACE_OS::gethrtime ();
135
task0.activate (THR_NEW_LWP | THR_JOINABLE);
136
task1.activate (THR_NEW_LWP | THR_JOINABLE);
137
task2.activate (THR_NEW_LWP | THR_JOINABLE);
138
task3.activate (THR_NEW_LWP | THR_JOINABLE);
140
task0.thr_mgr()->wait ();
141
ACE_hrtime_t test_end = ACE_OS::gethrtime ();
143
ACE_DEBUG ((LM_DEBUG, "Threads finished\n"));
145
ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration...."));
146
ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor ();
147
ACE_DEBUG ((LM_DEBUG, "done\n"));
149
ACE_Basic_Stats totals;
150
task0.accumulate_and_dump (totals, "Task[0]", gsf);
151
task1.accumulate_and_dump (totals, "Task[1]", gsf);
152
task2.accumulate_and_dump (totals, "Task[2]", gsf);
153
task3.accumulate_and_dump (totals, "Task[3]", gsf);
155
totals.dump_results ("Total", gsf);
157
ACE_Throughput_Stats::dump_throughput ("Total", gsf,
158
test_end - test_start,
159
totals.samples_count ());
163
roundtrip->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
169
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught:");
173
ACE_CHECK_RETURN (-1);