1 #include "ace/Get_Opt.h"
2 #include "ace/Argv_Type_Converter.h"
3 #include "ace/Profile_Timer.h"
4 #include "ace/Read_Buffer.h"
7 static ACE_TCHAR
*IOR
= 0;
8 static int iterations
= 1;
10 static int shutdown_server
= 0;
11 static CORBA::ULong timeout
= 5;
12 static int timed_method
= 0;
15 parse_args (int argc
, ACE_TCHAR
**argv
)
17 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("f:k:i:T:otx"));
20 while ((c
= get_opts ()) != -1)
24 IOR
= get_opts
.opt_arg ();
36 iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
40 timeout
= static_cast<CORBA::ULong
> (ACE_OS::atoi (get_opts
.opt_arg ()));
49 ACE_ERROR_RETURN ((LM_ERROR
,
53 "-t timed operations "
54 "-T timeout for timed operations "
63 ACE_ERROR_RETURN ((LM_ERROR
,
64 "Please specify the IOR for the servant\n"), -1);
66 // Indicates successful parsing of command line.
71 print_stats (ACE_Profile_Timer::ACE_Elapsed_Time
&elapsed_time
,
76 elapsed_time
.real_time
*= ACE_ONE_SECOND_IN_MSECS
;
77 elapsed_time
.user_time
*= ACE_ONE_SECOND_IN_MSECS
;
78 elapsed_time
.system_time
*= ACE_ONE_SECOND_IN_MSECS
;
80 elapsed_time
.real_time
/= iterations
;
81 elapsed_time
.user_time
/= iterations
;
82 elapsed_time
.system_time
/= iterations
;
84 double tmp
= 1000 / elapsed_time
.real_time
;
87 "\titerations\t = %d,\n"
88 "\treal_time\t = %0.06f ms,\n"
89 "\tuser_time\t = %0.06f ms,\n"
90 "\tsystem_time\t = %0.06f ms,\n"
91 "\t%0.00f calls/second\n",
93 elapsed_time
.real_time
< 0.0 ? 0.0 : elapsed_time
.real_time
,
94 elapsed_time
.user_time
< 0.0 ? 0.0 : elapsed_time
.user_time
,
95 elapsed_time
.system_time
< 0.0 ? 0.0 : elapsed_time
.system_time
,
96 tmp
< 0.0 ? 0.0 : tmp
));
100 "\tNo time stats printed. Zero iterations or error occurred.\n"));
104 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
109 // Initialize the ORB
111 CORBA::ORB_init (argc
, argv
);
113 // Initialize options based on command-line arguments.
114 int parse_args_result
=
115 parse_args (argc
, argv
);
116 if (parse_args_result
!= 0)
117 return parse_args_result
;
119 // Get an object reference from the argument string.
120 CORBA::Object_var object
=
121 orb
->string_to_object (IOR
);
123 // Try to narrow the object reference to a test reference.
124 test_var test
= test::_narrow (object
.in ());
126 CORBA::String_var ior
=
127 orb
->object_to_string (test
.in ());
129 ACE_DEBUG ((LM_DEBUG
,
130 "\nConnecting to: %C\n\n",
133 ACE_Profile_Timer timer
;
134 ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time
;
136 // We start an ACE_Profile_Timer here...
141 for (i
= 0; i
< iterations
; i
++)
143 if (oneway
&& timed_method
)
145 test
->timed_oneway_method (timeout
);
149 test
->oneway_method ();
151 else if (!oneway
&& timed_method
)
153 test
->timed_method (timeout
);
163 timer
.elapsed_time (elapsed_time
);
165 // compute average time.
166 print_stats (elapsed_time
, i
);
175 catch (const CORBA::Exception
& ex
)
177 ex
._tao_print_exception ("Error!");