1 #include "tao/PortableServer/PortableServer.h"
2 #include "tao/ORB_Constants.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/Sched_Params.h"
6 #include "ace/High_Res_Timer.h"
7 #include "ace/Sched_Params.h"
9 #include "ace/Sample_History.h"
10 #include "ace/OS_NS_stdio.h"
11 #include "ace/OS_NS_errno.h"
13 int niterations
= 10000;
14 int do_dump_history
= 0;
15 ACE_High_Res_Timer::global_scale_factor_type gsf
;
18 parse_args (int argc
, ACE_TCHAR
*argv
[])
20 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("hi:"));
23 while ((c
= get_opts ()) != -1)
31 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
36 ACE_ERROR_RETURN ((LM_ERROR
,
44 // Indicates successful parsing of the command line
49 set_rt_scheduling (void)
52 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
53 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
54 priority
= ACE_Sched_Params::next_priority (ACE_SCHED_FIFO
,
56 // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
58 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
60 ACE_SCOPE_PROCESS
)) != 0)
62 if (ACE_OS::last_error () == EPERM
)
65 "server (%P|%t): user is not superuser, "
66 "test runs in time-shared class\n"));
70 "server (%P|%t): sched_params failed\n"));
75 object_creation_test (PortableServer::POA_ptr poa
,
76 int create_reference_with_id
)
79 "\nCreating %d object references with %s\n",
81 create_reference_with_id
?
82 "create_reference_with_id" :
85 ACE_Sample_History
creation (niterations
);
87 for (int i
= 0; i
!= niterations
; ++i
)
90 ACE_OS::sprintf (buf
, "Object_%8.8x", i
);
91 PortableServer::ObjectId_var oid
92 (PortableServer::string_to_ObjectId (buf
));
97 CORBA::Object_var object
;
98 if (create_reference_with_id
)
101 poa
->create_reference_with_id (oid
.in (),
102 "IDL:Test/Simple:1.0");
107 poa
->create_reference ("IDL:Test/Simple:1.0");
110 ACE_hrtime_t now
= ACE_OS::gethrtime ();
111 creation
.sample (now
- start
);
116 creation
.dump_samples (ACE_TEXT("HISTORY"), gsf
);
119 ACE_Basic_Stats creation_stats
;
120 creation
.collect_basic_stats (creation_stats
);
121 creation_stats
.dump_results (ACE_TEXT("Creation"), gsf
);
125 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
127 set_rt_scheduling ();
132 CORBA::ORB_init (argc
, argv
);
134 CORBA::Object_var poa_object
=
135 orb
->resolve_initial_references ("RootPOA");
137 if (CORBA::is_nil (poa_object
.in ()))
138 ACE_ERROR_RETURN ((LM_ERROR
,
139 " (%P|%t) Unable to initialize the POA.\n"),
142 PortableServer::POA_var root_poa
=
143 PortableServer::POA::_narrow (poa_object
.in ());
145 PortableServer::POAManager_var poa_manager
=
146 root_poa
->the_POAManager ();
148 poa_manager
->activate ();
150 if (parse_args (argc
, argv
) != 0)
153 CORBA::PolicyList
policies(1); policies
.length (1);
156 root_poa
->create_id_assignment_policy (PortableServer::USER_ID
);
158 PortableServer::POA_var child_poa
=
159 root_poa
->create_POA ("TestPOA",
163 gsf
= ACE_High_Res_Timer::global_scale_factor ();
165 object_creation_test (root_poa
.in (),
166 0 // POA::create_reference
169 object_creation_test (child_poa
.in (),
170 1 // POA::create_reference_with_id
173 root_poa
->destroy (1, 1);
177 catch (const CORBA::Exception
& ex
)
179 ex
._tao_print_exception ("Exception caught:");