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;
19 parse_args (int argc
, ACE_TCHAR
*argv
[])
21 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("hxk:i:n:r:"));
24 while ((c
= get_opts ()) != -1)
36 ior
= get_opts
.opt_arg ();
40 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
45 static_cast<float> (ACE_OS::atoi (get_opts
.opt_arg ()));
49 number
= ACE_OS::atoi (get_opts
.opt_arg ());
54 ACE_ERROR_RETURN ((LM_ERROR
,
58 "-x (disable shutdown) "
65 // Indicates successful parsing of the command line
70 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
73 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
74 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
75 // Enable FIFO scheduling
76 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
78 ACE_SCOPE_PROCESS
)) != 0)
80 if (ACE_OS::last_error () == EPERM
)
83 "client (%P|%t): user is not superuser, "
84 "test runs in time-shared class\n"));
88 "client (%P|%t): sched_params failed\n"));
94 CORBA::ORB_init (argc
, argv
);
96 if (parse_args (argc
, argv
) != 0)
99 CORBA::Object_var object
=
100 orb
->string_to_object (ior
);
102 Test::Roundtrip_var roundtrip
=
103 Test::Roundtrip::_narrow (object
.in ());
105 if (CORBA::is_nil (roundtrip
.in ()))
107 ACE_ERROR_RETURN ((LM_ERROR
,
108 "Nil Test::Roundtrip reference <%s>\n",
112 for (int j
= 0; j
< 100; ++j
)
114 ACE_hrtime_t start
= 0;
115 (void) roundtrip
->test_method (start
, number
);
118 ACE_Sample_History
history (niterations
);
120 // const float usecs = 1.0 / rate * 1e6;
122 // ACE_Time_Value tv (0, static_cast<const long> (usecs));
124 // const timespec ts = tv;
126 ACE_hrtime_t test_start
= ACE_OS::gethrtime ();
127 for (int i
= 0; i
< niterations
; ++i
)
129 ACE_hrtime_t start
= ACE_OS::gethrtime ();
134 //(void) ACE_OS::nanosleep (&ts, 0);
135 //prime_number = ACE::is_prime (699999, 2, 349999);
139 (void) roundtrip
->test_method (start
, number
);
141 ACE_hrtime_t now
= ACE_OS::gethrtime ();
142 history
.sample (now
- start
);
145 ACE_hrtime_t test_end
= ACE_OS::gethrtime ();
147 ACE_DEBUG ((LM_DEBUG
, "test finished\n"));
149 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
150 ACE_High_Res_Timer::global_scale_factor_type gsf
=
151 ACE_High_Res_Timer::global_scale_factor ();
152 ACE_DEBUG ((LM_DEBUG
, "done\n"));
156 history
.dump_samples (ACE_TEXT("HISTORY"), gsf
);
159 ACE_Basic_Stats stats
;
160 history
.collect_basic_stats (stats
);
161 stats
.dump_results (ACE_TEXT("Total"), gsf
);
163 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
164 test_end
- test_start
,
165 stats
.samples_count ());
169 roundtrip
->shutdown ();
172 catch (const CORBA::Exception
& ex
)
174 ex
._tao_print_exception ("Exception caught:");