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/Sample_History.h"
8 #include "ace/OS_NS_errno.h"
10 #include "tao/Strategies/advanced_resource.h"
12 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
13 int niterations
= 100;
14 int do_dump_history
= 0;
18 parse_args (int argc
, ACE_TCHAR
*argv
[])
20 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("hxk:i:"));
23 while ((c
= get_opts ()) != -1)
35 ior
= get_opts
.opt_arg ();
39 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
44 ACE_ERROR_RETURN ((LM_ERROR
,
48 "-x (disable shutdown) "
54 // Indicates successful parsing of the command line
59 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
62 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
63 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
64 // 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 Test::Roundtrip_var roundtrip
=
93 Test::Roundtrip::_narrow (object
.in ());
95 if (CORBA::is_nil (roundtrip
.in ()))
97 ACE_ERROR_RETURN ((LM_ERROR
,
98 "Nil Test::Roundtrip reference <%s>\n",
103 for (int j
= 0; j
< 100; ++j
)
105 ACE_hrtime_t start
= 0;
106 (void) roundtrip
->test_method (start
);
109 ACE_Sample_History
history (niterations
);
111 ACE_hrtime_t test_start
= ACE_OS::gethrtime ();
112 for (int i
= 0; i
< niterations
; ++i
)
114 ACE_hrtime_t start
= ACE_OS::gethrtime ();
116 (void) roundtrip
->test_method (start
);
118 ACE_hrtime_t now
= ACE_OS::gethrtime ();
119 history
.sample (now
- start
);
122 ACE_hrtime_t test_end
= ACE_OS::gethrtime ();
124 ACE_DEBUG ((LM_DEBUG
, "test finished\n"));
126 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
127 ACE_High_Res_Timer::global_scale_factor_type gsf
=
128 ACE_High_Res_Timer::global_scale_factor ();
129 ACE_DEBUG ((LM_DEBUG
, "done\n"));
133 history
.dump_samples (ACE_TEXT("HISTORY"), gsf
);
136 ACE_Basic_Stats stats
;
137 history
.collect_basic_stats (stats
);
138 stats
.dump_results (ACE_TEXT("Total"), gsf
);
140 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
141 test_end
- test_start
,
142 stats
.samples_count ());
146 roundtrip
->shutdown ();
149 catch (const CORBA::Exception
& ex
)
151 ex
._tao_print_exception ("Exception caught:");