2 #include "ace/Get_Opt.h"
3 #include "ace/High_Res_Timer.h"
4 #include "ace/Sched_Params.h"
6 #include "ace/Sample_History.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
= 100;
13 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:n:r:"));
23 while ((c
= get_opts ()) != -1)
35 ior
= get_opts
.opt_arg ();
39 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
43 rate
= ACE_OS::atoi (get_opts
.opt_arg ());
47 number
= ACE_OS::atoi (get_opts
.opt_arg ());
52 ACE_ERROR_RETURN ((LM_ERROR
,
56 "-x (disable shutdown) "
63 // Indicates successful parsing of the command line
68 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
71 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
72 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
73 // Enable FIFO scheduling
74 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
76 ACE_SCOPE_PROCESS
)) != 0)
78 if (ACE_OS::last_error () == EPERM
)
81 "client (%P|%t): user is not superuser, "
82 "test runs in time-shared class\n"));
86 "client (%P|%t): sched_params failed\n"));
92 CORBA::ORB_init (argc
, argv
);
94 if (parse_args (argc
, argv
) != 0)
97 CORBA::Object_var object
=
98 orb
->string_to_object (ior
);
100 Test::Roundtrip_var roundtrip
=
101 Test::Roundtrip::_narrow (object
.in ());
103 if (CORBA::is_nil (roundtrip
.in ()))
105 ACE_ERROR_RETURN ((LM_ERROR
,
106 "Nil Test::Roundtrip reference <%s>\n",
111 for (int j
= 0; j
< 100; ++j
)
113 ACE_hrtime_t start
= 0;
114 (void) roundtrip
->test_method (start
, number
);
117 ACE_Sample_History
history (niterations
);
119 const float usecs
= 1.0 / rate
* 1e6
;
121 ACE_Time_Value
tv (0, static_cast<const long> (usecs
));
123 // const timespec ts = tv;
125 ACE_hrtime_t test_start
= ACE_OS::gethrtime ();
126 for (int i
= 0; i
< niterations
; ++i
)
128 ACE_hrtime_t start
= ACE_OS::gethrtime ();
133 //(void) ACE_OS::nanosleep (&ts, 0);
134 //prime_number = ACE::is_prime (699999, 2, 349999);
138 (void) roundtrip
->test_method (start
, number
);
140 ACE_hrtime_t now
= ACE_OS::gethrtime ();
141 history
.sample (now
- start
);
144 ACE_hrtime_t test_end
= ACE_OS::gethrtime ();
146 ACE_DEBUG ((LM_DEBUG
, "test finished\n"));
148 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
149 ACE_High_Res_Timer::global_scale_factor_type gsf
=
150 ACE_High_Res_Timer::global_scale_factor ();
151 ACE_DEBUG ((LM_DEBUG
, "done\n"));
155 history
.dump_samples (ACE_TEXT("HISTORY"), gsf
);
158 ACE_Basic_Stats stats
;
159 history
.collect_basic_stats (stats
);
160 stats
.dump_results (ACE_TEXT("Total"), gsf
);
162 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
163 test_end
- test_start
,
164 stats
.samples_count ());
168 roundtrip
->shutdown ();
171 catch (const CORBA::Exception
& ex
)
173 ex
._tao_print_exception ("Exception caught:");