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) "
53 // Indicates successful parsing of the command line
58 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
61 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
62 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
63 // Enable FIFO scheduling
65 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
67 ACE_SCOPE_PROCESS
)) != 0)
69 if (ACE_OS::last_error () == EPERM
)
72 "client (%P|%t): user is not superuser, "
73 "test runs in time-shared class\n"));
77 "client (%P|%t): sched_params failed\n"));
83 CORBA::ORB_init (argc
, argv
);
85 if (parse_args (argc
, argv
) != 0)
88 CORBA::Object_var object
=
89 orb
->string_to_object (ior
);
91 Test::Roundtrip_var roundtrip
=
92 Test::Roundtrip::_narrow (object
.in ());
94 if (CORBA::is_nil (roundtrip
.in ()))
96 ACE_ERROR_RETURN ((LM_ERROR
,
97 "Nil Test::Roundtrip reference <%s>\n",
102 for (int j
= 0; j
< 100; ++j
)
104 ACE_hrtime_t start
= 0;
105 (void) roundtrip
->test_method (start
);
108 ACE_Sample_History
history (niterations
);
110 ACE_hrtime_t test_start
= ACE_OS::gethrtime ();
111 for (int i
= 0; i
< niterations
; ++i
)
113 ACE_hrtime_t start
= ACE_OS::gethrtime ();
115 (void) roundtrip
->test_method (start
);
117 ACE_hrtime_t now
= ACE_OS::gethrtime ();
118 history
.sample (now
- start
);
121 ACE_hrtime_t test_end
= ACE_OS::gethrtime ();
123 ACE_DEBUG ((LM_DEBUG
, "test finished\n"));
125 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
126 ACE_High_Res_Timer::global_scale_factor_type gsf
=
127 ACE_High_Res_Timer::global_scale_factor ();
128 ACE_DEBUG ((LM_DEBUG
, "done\n"));
132 history
.dump_samples (ACE_TEXT("HISTORY"), gsf
);
135 ACE_Basic_Stats stats
;
136 history
.collect_basic_stats (stats
);
137 stats
.dump_results (ACE_TEXT("Total"), gsf
);
139 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
140 test_end
- test_start
,
141 stats
.samples_count ());
145 roundtrip
->shutdown ();
148 catch (const CORBA::Exception
& ex
)
150 ex
._tao_print_exception ("Exception caught:");