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
[])
108 // Initialize the ORB
110 CORBA::ORB_init (argc
, argv
);
112 // Initialize options based on command-line arguments.
113 int parse_args_result
=
114 parse_args (argc
, argv
);
115 if (parse_args_result
!= 0)
116 return parse_args_result
;
118 // Get an object reference from the argument string.
119 CORBA::Object_var object
=
120 orb
->string_to_object (IOR
);
122 // Try to narrow the object reference to a test reference.
123 test_var test
= test::_narrow (object
.in ());
125 CORBA::String_var ior
=
126 orb
->object_to_string (test
.in ());
128 ACE_DEBUG ((LM_DEBUG
,
129 "\nConnecting to: %C\n\n",
132 ACE_Profile_Timer timer
;
133 ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time
;
135 // We start an ACE_Profile_Timer here...
140 for (i
= 0; i
< iterations
; i
++)
142 if (oneway
&& timed_method
)
144 test
->timed_oneway_method (timeout
);
148 test
->oneway_method ();
150 else if (!oneway
&& timed_method
)
152 test
->timed_method (timeout
);
162 timer
.elapsed_time (elapsed_time
);
164 // compute average time.
165 print_stats (elapsed_time
, i
);
174 catch (const CORBA::Exception
& ex
)
176 ex
._tao_print_exception ("Error!");