2 #include "ace/Get_Opt.h"
3 #include "ace/Sched_Params.h"
4 #include "ace/High_Res_Timer.h"
5 #include "ace/Sched_Params.h"
7 #include "ace/Sample_History.h"
8 #include "ace/OS_NS_errno.h"
10 int niterations
= 10000;
11 int do_dump_history
= 0;
14 parse_args (int argc
, ACE_TCHAR
*argv
[])
16 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("hi:"));
19 while ((c
= get_opts ()) != -1)
27 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
32 ACE_ERROR_RETURN ((LM_ERROR
,
40 // Indicates successful parsing of the command line
45 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
48 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
49 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
50 priority
= ACE_Sched_Params::next_priority (ACE_SCHED_FIFO
,
52 // Enable FIFO scheduling
54 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
56 ACE_SCOPE_PROCESS
)) != 0)
58 if (ACE_OS::last_error () == EPERM
)
61 "server (%P|%t): user is not superuser, "
62 "test runs in time-shared class\n"));
66 "server (%P|%t): sched_params failed\n"));
72 CORBA::ORB_init (argc
, argv
);
74 CORBA::Object_var poa_object
=
75 orb
->resolve_initial_references("RootPOA");
77 if (CORBA::is_nil (poa_object
.in ()))
78 ACE_ERROR_RETURN ((LM_ERROR
,
79 " (%P|%t) Unable to initialize the POA.\n"),
82 PortableServer::POA_var root_poa
=
83 PortableServer::POA::_narrow (poa_object
.in ());
85 PortableServer::POAManager_var poa_manager
=
86 root_poa
->the_POAManager ();
88 poa_manager
->activate ();
90 if (parse_args (argc
, argv
) != 0)
93 Test::Simple_Sequence
references (niterations
);
94 references
.length (niterations
);
96 ACE_Sample_History
activation (niterations
);
98 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
99 ACE_High_Res_Timer::global_scale_factor_type gsf
=
100 ACE_High_Res_Timer::global_scale_factor ();
101 ACE_DEBUG ((LM_DEBUG
, "done\n"));
103 ACE_DEBUG ((LM_DEBUG
, "Activating %d objects\n", niterations
));
104 for (int i
= 0; i
!= niterations
; ++i
)
106 ACE_hrtime_t start
= ACE_OS::gethrtime ();
109 ACE_NEW_RETURN (simple_impl
,
112 PortableServer::ServantBase_var
owner_transfer(simple_impl
);
115 simple_impl
->_this ();
117 ACE_hrtime_t now
= ACE_OS::gethrtime ();
118 activation
.sample (now
- start
);
120 ACE_DEBUG ((LM_DEBUG
, "Activations completed\n"));
124 activation
.dump_samples (ACE_TEXT("ACTIVATION_HISTORY"), gsf
);
127 ACE_Basic_Stats activation_stats
;
128 activation
.collect_basic_stats (activation_stats
);
129 activation_stats
.dump_results (ACE_TEXT("Activation"), gsf
);
131 ACE_Sample_History
destruction (niterations
);
133 ACE_DEBUG ((LM_DEBUG
, "Destroying %d objects\n", niterations
));
134 for (int j
= 0; j
!= niterations
; ++j
)
136 ACE_hrtime_t start
= ACE_OS::gethrtime ();
138 references
[j
]->destroy ();
140 ACE_hrtime_t now
= ACE_OS::gethrtime ();
141 destruction
.sample (now
- start
);
143 ACE_DEBUG ((LM_DEBUG
, "Destructions completed\n"));
147 destruction
.dump_samples (ACE_TEXT("DESTRUCTION_HISTORY"), gsf
);
150 ACE_Basic_Stats destruction_stats
;
151 destruction
.collect_basic_stats (destruction_stats
);
152 destruction_stats
.dump_results (ACE_TEXT("Destruction"), gsf
);
154 root_poa
->destroy (true, true);
158 catch (const CORBA::Exception
& ex
)
160 ex
._tao_print_exception ("Exception caught:");