3 #include "Client_ORBInitializer.h"
4 #include "Interceptor_Type.h"
7 #include "tao/ORBInitializer_Registry.h"
9 #include "ace/Get_Opt.h"
10 #include "ace/OS_NS_errno.h"
12 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
14 int register_interceptor
= 1;
17 parse_args (int argc
, ACE_TCHAR
*argv
[])
19 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("ef:n:"));
22 while ((c
= get_opts ()) != -1)
28 ior
= get_opts
.opt_arg ();
31 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
35 ACE_ERROR_RETURN ((LM_ERROR
,
37 "-v -r <register_interceptor> "
47 run_test (Test_Interceptors::Secure_Vault_ptr server
)
50 const char user
[] = "root";
52 ACE_Throughput_Stats throughput
;
54 ACE_DEBUG ((LM_DEBUG
, "High res. timer calibration...."));
55 ACE_High_Res_Timer::global_scale_factor_type gsf
=
56 ACE_High_Res_Timer::global_scale_factor ();
57 ACE_DEBUG ((LM_DEBUG
, "done\n"));
59 marker
.accumulate_into (throughput
, 1);
60 ACE_hrtime_t throughput_base
= ACE_OS::gethrtime ();
61 for (i
= 0; i
< niterations
; ++i
)
63 // Record current time.
64 ACE_hrtime_t latency_base
= ACE_OS::gethrtime ();
68 // Grab timestamp again.
69 ACE_hrtime_t now
= ACE_OS::gethrtime ();
72 marker
.sample (now
- throughput_base
,
76 if (TAO_debug_level
> 0 && i
% 100 == 0)
77 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) iteration = %d\n", i
));
80 marker
.dump_stats (ACE_TEXT ("Ready method "), gsf
, 1);
84 marker
.accumulate_into (throughput
, 2);
85 throughput_base
= ACE_OS::gethrtime ();
87 for (i
= 0; i
< niterations
; ++i
)
89 // Record current time.
90 ACE_hrtime_t latency_base
= ACE_OS::gethrtime ();
92 server
->authenticate (user
);
94 // Grab timestamp again.
95 ACE_hrtime_t now
= ACE_OS::gethrtime ();
98 marker
.sample (now
- throughput_base
,
102 if (TAO_debug_level
> 0 && i
% 100 == 0)
103 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) iteration = %d\n", i
));
105 marker
.dump_stats (ACE_TEXT ("Authenticate method "), gsf
, 2);
107 catch (const Test_Interceptors::Invalid
&)
109 ACE_DEBUG ((LM_DEBUG
, "Invalid user\n"));
112 Test_Interceptors::Secure_Vault::Record record
;
113 record
.check_num
= 1;
114 record
.amount
= 1000;
117 marker
.accumulate_into (throughput
, 3);
118 throughput_base
= ACE_OS::gethrtime ();
120 for (i
= 0; i
< niterations
; ++i
)
122 // Record current time.
123 ACE_hrtime_t latency_base
= ACE_OS::gethrtime ();
125 server
->update_records (id
,
128 // Grab timestamp again.
129 ACE_hrtime_t now
= ACE_OS::gethrtime ();
131 // Record statistics.
132 marker
.sample (now
- throughput_base
,
136 if (TAO_debug_level
> 0 && i
% 100 == 0)
137 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) iteration = %d\n", i
));
140 marker
.dump_stats (ACE_TEXT ("update records method "), gsf
, 3);
145 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
148 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
149 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
150 // Enable FIFO scheduling
152 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
154 ACE_SCOPE_PROCESS
)) != 0)
156 if (ACE_OS::last_error () == EPERM
)
158 ACE_DEBUG ((LM_DEBUG
,
159 "client (%P|%t): user is not superuser, "
160 "test runs in time-shared class\n"));
163 ACE_ERROR ((LM_ERROR
,
164 "client (%P|%t): sched_params failed\n"));
167 int interceptor_type
;
168 get_interceptor_type (argc
, argv
, interceptor_type
);
172 PortableInterceptor::ORBInitializer_ptr temp_initializer
;
174 ACE_NEW_RETURN (temp_initializer
,
175 Client_ORBInitializer (interceptor_type
),
176 -1); // No exceptions yet!
177 PortableInterceptor::ORBInitializer_var initializer
=
180 PortableInterceptor::register_orb_initializer (initializer
.in ());
183 CORBA::ORB_init (argc
, argv
);
185 if (parse_args (argc
, argv
) != 0)
188 CORBA::Object_var object
=
189 orb
->string_to_object (ior
);
191 Test_Interceptors::Secure_Vault_var server
=
192 Test_Interceptors::Secure_Vault::_narrow (object
.in ());
194 if (CORBA::is_nil (server
.in ()))
196 ACE_ERROR_RETURN ((LM_ERROR
,
197 "Object reference <%s> is nil.\n",
202 ACE_DEBUG ((LM_DEBUG
, "\nFunctionality test begins now...\n"));
204 // This test is useful for benchmarking the differences when
205 // the same method is intercepted by different interceptors
206 // wanting to achieve different functionality.
207 run_test (server
.in ());
211 catch (const CORBA::Exception
& ex
)
213 ex
._tao_print_exception ("Caught exception:");