2 #include "ace/High_Res_Timer.h"
3 #include "ace/Get_Opt.h"
4 #include "tao/Strategies/advanced_resource.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
7 int message_size
= 2048;
8 int message_count
= 10 * 1024;
13 parse_args (int argc
, ACE_TCHAR
*argv
[])
15 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:b:i:n:x"));
18 while ((c
= get_opts ()) != -1)
22 ior
= get_opts
.opt_arg ();
26 message_size
= ACE_OS::atoi (get_opts
.opt_arg ());
30 message_count
= ACE_OS::atoi (get_opts
.opt_arg ());
34 test_runs
= ACE_OS::atoi (get_opts
.opt_arg ());
43 ACE_ERROR_RETURN ((LM_ERROR
,
48 "-n <test_repetitions> "
53 // Indicates successful parsing of the command line
58 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
63 CORBA::ORB_init (argc
, argv
);
65 if (parse_args (argc
, argv
) != 0)
68 CORBA::Object_var tmp
=
69 orb
->string_to_object(ior
);
71 Test::Receiver_Factory_var receiver_factory
=
72 Test::Receiver_Factory::_narrow(tmp
.in ());
74 if (CORBA::is_nil (receiver_factory
.in ()))
76 ACE_ERROR_RETURN ((LM_DEBUG
,
77 "Nil receiver factory reference <%s>\n",
82 ACE_High_Res_Timer::global_scale_factor_type gsf
=
83 ACE_High_Res_Timer::global_scale_factor ();
85 Test::Message message
;
87 for (int j
= 0; j
!= test_runs
; ++j
)
90 "Testing with %d bytes per message\n",
93 message
.the_payload
.length (message_size
);
95 Test::Receiver_var receiver
=
96 receiver_factory
->create_receiver ();
98 ACE_hrtime_t start
= ACE_OS::gethrtime ();
99 for (int i
= 0; i
!= message_count
; ++i
)
101 message
.message_id
= i
;
102 receiver
->receive_data (message
);
106 ACE_hrtime_t elapsed_time
= ACE_OS::gethrtime () - start
;
108 // convert to microseconds
109 ACE_UINT32 usecs
= ACE_UINT32(elapsed_time
/ gsf
);
112 (1000000.0 * message_count
* message_size
) / usecs
;
113 double kbytes
= bytes
/ 1024;
114 double mbytes
= kbytes
/ 1024;
115 double mbits
= bytes
* 8 / 1000000;
117 ACE_DEBUG ((LM_DEBUG
,
118 "Sender[%d] %f (bytes/sec), "
120 "Sender[%d] %f (Mb/sec), %f Mbits\n",
121 message_size
, bytes
, kbytes
,
122 message_size
, mbytes
, mbits
));
129 receiver_factory
->shutdown ();
134 catch (const CORBA::Exception
& ex
)
136 ex
._tao_print_exception ("Exception caught:");