2 #include "Client_Task.h"
4 #include "ace/Throughput_Stats.h"
5 #include "ace/Sample_History.h"
6 #include "ace/High_Res_Timer.h"
7 #include "ace/SString.h"
9 Client_Task::Client_Task (Test::Roundtrip_ptr reference
,
11 ACE_Thread_Manager
*thr_mgr
)
12 : ACE_Task_Base (thr_mgr
),
13 niterations (iterations
),
14 remote_ref_ (Test::Roundtrip::_duplicate (reference
))
24 if (CORBA::is_nil (this->remote_ref_
.in ()))
26 ACE_ERROR_RETURN ((LM_DEBUG
,
27 "Nil Test::Roundtrip reference\n"),
31 //// Start Test ///////////////////////////////
32 CORBA::Long test_time
= 1234L;
35 for (int i
=0; i
< 1000; i
++)
36 this->remote_ref_
->test_method (test_time
);
38 // Start for actual Measurements
39 ACE_Sample_History
history (niterations
);
41 ACE_hrtime_t test_start
= ACE_OS::gethrtime ();
42 for (int itercounter
= 0; itercounter
< niterations
; ++itercounter
)
44 ACE_hrtime_t start
= ACE_OS::gethrtime ();
46 (void) this->remote_ref_
->test_method (start
);
48 ACE_hrtime_t now
= ACE_OS::gethrtime ();
49 history
.sample (now
- start
);
52 ACE_hrtime_t test_end
= ACE_OS::gethrtime ();
54 ACE_DEBUG ((LM_DEBUG
, "test finished\n"));
56 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
57 ACE_High_Res_Timer::global_scale_factor_type gsf
=
58 ACE_High_Res_Timer::global_scale_factor ();
59 ACE_DEBUG ((LM_DEBUG
, "done\n"));
61 ACE_Basic_Stats stats
;
62 history
.collect_basic_stats (stats
);
63 stats
.dump_results (ACE_TEXT("Total"), gsf
);
65 ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf
,
66 test_end
- test_start
,
67 stats
.samples_count ());
69 //shutdown the server ORB
70 this->remote_ref_
->shutdown ();
73 catch (const CORBA::Exception
& ex
)
75 ex
._tao_print_exception ("Exception caught:");