2 #include "ace/Get_Opt.h"
3 #include "ace/High_Res_Timer.h"
4 #include "ace/Sched_Params.h"
6 #include "ace/Sample_History.h"
7 #include "ace/OS_NS_errno.h"
9 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
10 int niterations
= 100;
11 int do_dump_history
= 0;
15 parse_args (int argc
, ACE_TCHAR
*argv
[])
17 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("hxk:i:"));
20 while ((c
= get_opts ()) != -1)
32 ior
= get_opts
.opt_arg ();
36 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
41 ACE_ERROR_RETURN ((LM_ERROR
,
45 "-x (disable shutdown) "
50 // Indicates successful parsing of the command line
55 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
58 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
59 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
60 // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
62 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
64 ACE_SCOPE_PROCESS
)) != 0)
66 if (ACE_OS::last_error () == EPERM
)
69 "client (%P|%t): user is not superuser, "
70 "test runs in time-shared class\n"));
74 "client (%P|%t): sched_params failed\n"));
80 CORBA::ORB_init (argc
, argv
);
82 if (parse_args (argc
, argv
) != 0)
85 CORBA::Object_var object
=
86 orb
->string_to_object (ior
);
88 Test::Factory_var factory
=
89 Test::Factory::_narrow (object
.in ());
91 if (CORBA::is_nil (factory
.in ()))
93 ACE_ERROR_RETURN ((LM_ERROR
,
94 "Nil Test::Factory reference <%s>\n",
99 Test::Simple_Sequence
references (niterations
);
100 references
.length (niterations
);
102 ACE_Sample_History
activation (niterations
);
104 ACE_DEBUG ((LM_DEBUG
, "High resolution timer calibration...."));
105 ACE_High_Res_Timer::global_scale_factor_type gsf
=
106 ACE_High_Res_Timer::global_scale_factor ();
107 ACE_DEBUG ((LM_DEBUG
, "done\n"));
109 ACE_DEBUG ((LM_DEBUG
, "Activating %d objects\n", niterations
));
110 for (int i
= 0; i
!= niterations
; ++i
)
112 ACE_hrtime_t start
= ACE_OS::gethrtime ();
115 factory
->create_simple_object ();
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
);
156 factory
->shutdown ();
159 catch (const CORBA::Exception
& ex
)
161 ex
._tao_print_exception ("Exception caught:");