3 #include "ace/High_Res_Timer.h"
9 , last_message_time_ (0)
10 , last_message_id_ (0)
15 Receiver::receive_data (const Test::Message
&the_message
)
17 ACE_hrtime_t now
= ACE_OS::gethrtime ();
18 if (this->message_count_
== 0)
20 this->start_time_
= now
;
24 if (this->last_message_id_
> the_message
.message_id
)
27 "ERROR: (%P|%t) Receiver::receive_data, "
28 "message out of sequence %d / %d\n",
29 the_message
.message_id
,
30 this->last_message_id_
));
33 this->last_message_id_
= the_message
.message_id
;
35 ++this->message_count_
;
36 this->byte_count_
+= the_message
.the_payload
.length ();
37 this->last_message_time_
= now
;
43 if (this->message_count_
== 0)
46 "ERROR: (%P|%t) Receiver::done, "
47 "no messages received\n"));
51 ACE_High_Res_Timer::global_scale_factor_type gsf
=
52 ACE_High_Res_Timer::global_scale_factor ();
54 ACE_hrtime_t elapsed_time
=
55 this->last_message_time_
- this->start_time_
;
57 // convert to microseconds
58 ACE_UINT32 usecs
= ACE_UINT32(elapsed_time
/ gsf
);
63 (1000000.0 * this->byte_count_
) / usecs
;
64 double kbytes
= bytes
/ 1024;
65 double mbytes
= kbytes
/ 1024;
66 double mbits
= bytes
* 8 / 1000000;
69 "Receiver %f (bytes/sec), %f (Kb/sec)\n"
70 "Receiver %f (Mb/sec), %f Mbits\n",
78 PortableServer::POA_var poa
= this->_default_POA ();
79 PortableServer::ObjectId_var oid
=
80 poa
->servant_to_id (this);
81 poa
->deactivate_object (oid
.in ());
83 catch (const CORBA::Exception
&){}