1 #include "Client_Task.h"
2 #include "tao/Strategies/advanced_resource.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/Sched_Params.h"
7 #include "ace/Throughput_Stats.h"
9 Client_Task::Client_Task (int &argc
, ACE_TCHAR
**argv
)
12 , ior_ (ACE_TEXT("file://test.ior"))
18 Client_Task::parse_args (void)
20 ACE_Get_Opt
get_opts (this->argc_
, this->argv_
, "k:n:O:");
23 while ((c
= get_opts ()) != -1)
29 this->ior_
= get_opts
.opt_arg ();
34 int iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
36 this->iterations_
= iterations
;
40 ACE_ERROR_RETURN ((LM_ERROR
,
42 "-k <file that contains IOR> "
51 // Indicates successful parsing of the command line
56 Client_Task::try_RT_scheduling (void)
59 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
60 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
61 priority
= ACE_Sched_Params::next_priority (ACE_SCHED_FIFO
,
64 // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
65 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
67 ACE_SCOPE_PROCESS
)) != 0)
72 "client (%P|%t): user is not superuser, "
73 "test runs in time-shared class\n"));
77 "client (%P|%t): sched_params failed\n"));
82 Client_Task::narrow_servant (CORBA::ORB_ptr orb
)
86 CORBA::Object_var object
=
87 orb
->string_to_object (this->ior_
);
90 Test::Roundtrip::_narrow (object
.in ());
92 if (CORBA::is_nil (this->roundtrip_
.in ()))
94 ACE_ERROR_RETURN ((LM_ERROR
,
95 "Nil Test::Roundtrip reference <%s>\n",
100 catch (const CORBA::Exception
& ex
)
102 ex
._tao_print_exception ("Exception caught trying to narrow servant\n");
109 Client_Task::run_test (void)
111 ACE_hrtime_t test_start
= 0;
112 ACE_hrtime_t test_end
= 0;
116 test_start
= ACE_OS::gethrtime ();
118 this->roundtrip_
->start_test ();
122 this->roundtrip_
->end_test ();
124 test_end
= ACE_OS::gethrtime ();
126 catch (const CORBA::Exception
&)
132 // High resolution timer calibration
133 ACE_High_Res_Timer::global_scale_factor_type gsf
=
134 ACE_High_Res_Timer::global_scale_factor ();
136 ACE_Basic_Stats totals
;
138 this->accumulate_and_dump (totals
, ACE_TEXT("Task"), gsf
);
140 totals
.dump_results (ACE_TEXT("Total"), gsf
);
142 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
143 test_end
- test_start
,
144 totals
.samples_count ());
150 Client_Task::svc (void)
154 for (int i
= 0; i
!= this->iterations_
; ++i
)
156 CORBA::ULongLong start
= ACE_OS::gethrtime ();
158 (void) this->roundtrip_
->test_method (start
);
160 ACE_hrtime_t now
= ACE_OS::gethrtime ();
161 this->latency_
.sample (now
- start
);
164 catch (const CORBA::Exception
&)
172 Client_Task::accumulate_and_dump (ACE_Basic_Stats
&totals
,
173 const ACE_TCHAR
*msg
,
174 ACE_High_Res_Timer::global_scale_factor_type gsf
)
176 totals
.accumulate (this->latency_
);
177 this->latency_
.dump_results (msg
, gsf
);