1 #include "Client_Task.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/High_Res_Timer.h"
4 #include "ace/Sched_Params.h"
6 #include "ace/Throughput_Stats.h"
7 #include "ace/OS_NS_errno.h"
9 #include "tao/Strategies/advanced_resource.h"
11 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
12 int niterations
= 1000;
16 parse_args (int argc
, ACE_TCHAR
*argv
[])
18 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("xk:i:"));
21 while ((c
= get_opts ()) != -1)
29 ior
= get_opts
.opt_arg ();
33 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
38 ACE_ERROR_RETURN ((LM_ERROR
,
42 "-x (disable shutdown) "
47 // Indicates successful parsing of the command line
52 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
55 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
56 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
57 // Enable FIFO scheduling
59 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
61 ACE_SCOPE_PROCESS
)) != 0)
63 if (ACE_OS::last_error () == EPERM
)
66 "client (%P|%t): user is not superuser, "
67 "test runs in time-shared class\n"));
71 "client (%P|%t): sched_params failed\n"));
77 CORBA::ORB_init (argc
, argv
);
79 if (parse_args (argc
, argv
) != 0)
82 CORBA::Object_var object
=
83 orb
->string_to_object (ior
);
85 Test::Roundtrip_var roundtrip
=
86 Test::Roundtrip::_narrow (object
.in ());
88 if (CORBA::is_nil (roundtrip
.in ()))
90 ACE_ERROR_RETURN ((LM_ERROR
,
91 "Nil Test::Roundtrip reference <%s>\n",
96 ACE_DEBUG ((LM_DEBUG
, "Starting threads\n"));
98 Client_Task
task0(roundtrip
.in (), niterations
);
99 Client_Task
task1(roundtrip
.in (), niterations
);
100 Client_Task
task2(roundtrip
.in (), niterations
);
101 Client_Task
task3(roundtrip
.in (), niterations
);
103 ACE_hrtime_t test_start
= ACE_OS::gethrtime ();
104 task0
.activate(THR_NEW_LWP
| THR_JOINABLE
);
105 task1
.activate(THR_NEW_LWP
| THR_JOINABLE
);
106 task2
.activate(THR_NEW_LWP
| THR_JOINABLE
);
107 task3
.activate(THR_NEW_LWP
| THR_JOINABLE
);
109 task0
.thr_mgr()->wait ();
110 ACE_hrtime_t test_end
= ACE_OS::gethrtime ();
112 ACE_DEBUG ((LM_DEBUG
, "Threads finished\n"));
114 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
115 ACE_High_Res_Timer::global_scale_factor_type gsf
=
116 ACE_High_Res_Timer::global_scale_factor ();
117 ACE_DEBUG ((LM_DEBUG
, "done\n"));
119 ACE_Basic_Stats totals
;
120 task0
.accumulate_and_dump (totals
, ACE_TEXT("Task[0]"), gsf
);
121 task1
.accumulate_and_dump (totals
, ACE_TEXT("Task[1]"), gsf
);
122 task2
.accumulate_and_dump (totals
, ACE_TEXT("Task[2]"), gsf
);
123 task3
.accumulate_and_dump (totals
, ACE_TEXT("Task[3]"), gsf
);
125 totals
.dump_results (ACE_TEXT("Total"), gsf
);
127 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
128 test_end
- test_start
,
129 totals
.samples_count ());
133 roundtrip
->shutdown ();
136 catch (const CORBA::Exception
& ex
)
138 ex
._tao_print_exception ("Exception caught:");