diff options
author | stanleyk <stanleyk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2013-02-05 21:11:03 +0000 |
---|---|---|
committer | stanleyk <stanleyk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2013-02-05 21:11:03 +0000 |
commit | 5e030faf84086ab02059fcbcc3faed224bd57b95 (patch) | |
tree | 3a62df45ac6ccf599fb07cf6a03d672456ce2e3d /TAO/orbsvcs/tests/Redundant_Naming | |
parent | 9d296f7fa51116ff7040ecb2ad18612cd94b5fd1 (diff) | |
download | ATCD-5e030faf84086ab02059fcbcc3faed224bd57b95.tar.gz |
Merge in OCI_Reliability_Enhancements branch.
Diffstat (limited to 'TAO/orbsvcs/tests/Redundant_Naming')
-rw-r--r-- | TAO/orbsvcs/tests/Redundant_Naming/client.cpp | 97 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/Redundant_Naming/run_test.pl | 10 |
2 files changed, 98 insertions, 9 deletions
diff --git a/TAO/orbsvcs/tests/Redundant_Naming/client.cpp b/TAO/orbsvcs/tests/Redundant_Naming/client.cpp index f54ada2e199..483b787c224 100644 --- a/TAO/orbsvcs/tests/Redundant_Naming/client.cpp +++ b/TAO/orbsvcs/tests/Redundant_Naming/client.cpp @@ -16,6 +16,7 @@ #include "tao/debug.h" #include "ace/Get_Opt.h" #include "ace/OS_NS_stdio.h" +#include "ace/High_Res_Timer.h" #if defined (_MSC_VER) # pragma warning (disable : 4250) @@ -184,6 +185,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) level1[0].id = CORBA::string_dup ("level1_context"); CosNaming::NamingContext_var level1_context; level1_context = root_context_1->bind_new_context (level1); + for (i=0; i<o_breath; i++) { // Instantiate a dummy object and bind it under the new context. @@ -191,12 +193,11 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) Test_Object_var obj1 = impl1->_this (); impl1->_remove_ref (); - CosNaming::Name obj_name; - obj_name.length (1); + level1.length (2); char wide_name[16]; ACE_OS::sprintf(wide_name, "obj_%d", i); - obj_name[0].id = CORBA::string_dup (wide_name); - level1_context->bind (obj_name, obj1.in ()); + level1[1].id = CORBA::string_dup (wide_name); + root_context_1->bind (level1, obj1.in ()); } } @@ -449,6 +450,94 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Redundancy test OK\n"))); + + // Test performance of binding a bunch of objects in one context + try + { + // Bind one context level under root. + CosNaming::Name level1; + level1.length (1); + level1[0].id = CORBA::string_dup ("perf_context"); + CosNaming::NamingContext_var perf_context; + perf_context = root_context_1->bind_new_context (level1); + + // Instantiate a dummy object and bind it under the new context. + My_Test_Object *impl1 = new My_Test_Object (i+1); + Test_Object_var obj1 = impl1->_this (); + impl1->_remove_ref (); + + int test_runs = 100; + ACE_High_Res_Timer::global_scale_factor_type gsf = + ACE_High_Res_Timer::global_scale_factor (); + + ACE_hrtime_t start = ACE_OS::gethrtime (); + + // Test how long it takes to bind + for (i=0; i<test_runs; i++) + { + level1.length (1); + char wide_name[16]; + ACE_OS::sprintf(wide_name, "obj_%d", i); + level1[0].id = CORBA::string_dup (wide_name); + perf_context->bind (level1, obj1.in ()); + } + + ACE_hrtime_t elapsed_time = ACE_OS::gethrtime () - start; + // convert to microseconds + ACE_UINT32 usecs = ACE_UINT32(elapsed_time / gsf); + double secs = usecs / 1000000.0; + + ACE_DEBUG ((LM_DEBUG, + "Bound %i objects in %.2f secs\n", + test_runs, secs)); + + // Test how long it takes to resolve + start = ACE_OS::gethrtime (); + for (i=0; i<test_runs; i++) + { + level1.length (1); + char wide_name[16]; + ACE_OS::sprintf(wide_name, "obj_%d", i); + level1[0].id = CORBA::string_dup (wide_name); + CORBA::Object_var result_obj_ref = perf_context->resolve (level1); + } + + elapsed_time = ACE_OS::gethrtime () - start; + // convert to microseconds + usecs = ACE_UINT32(elapsed_time / gsf); + secs = ((ACE_INT32) usecs) / 1000000.0; + + ACE_DEBUG ((LM_DEBUG, + "Resolved %i objects in %.2f secs\n", + test_runs, secs)); + + // Test how long it takes to unbind + start = ACE_OS::gethrtime (); + for (i=0; i<test_runs; i++) + { + level1.length (1); + char wide_name[16]; + ACE_OS::sprintf(wide_name, "obj_%d", i); + level1[0].id = CORBA::string_dup (wide_name); + perf_context->unbind (level1); + } + + elapsed_time = ACE_OS::gethrtime () - start; + // convert to microseconds + usecs = ACE_UINT32(elapsed_time / gsf); + secs = ((ACE_INT32) usecs) / 1000000.0; + + ACE_DEBUG ((LM_DEBUG, + "Unbound %i objects in %.2f secs\n", + test_runs, secs)); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception (ACE_TEXT ("ERROR: Exception during performance test.\n")); + return -1; + } + + // All tests have passed up to this point return 0; } diff --git a/TAO/orbsvcs/tests/Redundant_Naming/run_test.pl b/TAO/orbsvcs/tests/Redundant_Naming/run_test.pl index 849a56c486c..e89dc202e66 100755 --- a/TAO/orbsvcs/tests/Redundant_Naming/run_test.pl +++ b/TAO/orbsvcs/tests/Redundant_Naming/run_test.pl @@ -77,12 +77,12 @@ else { # Run two Naming Servers in redundant mode and one client. Client uses iors # in files to find the individual copies of the Naming Servers. -my $args = "-ORBEndPoint $ns_endpoint1 -o $test_iorfile1 -m 0 -r NameService"; +my $args = "-ORBEndPoint $ns_endpoint1 -o $iorfile1 -m 0 -r NameService"; my $prog = "$startdir/../../Naming_Service/tao_cosnaming"; $NS1 = $test->CreateProcess ("$prog", "$args"); -$test->DeleteFile ("iorfile1"); +$test->DeleteFile ($iorfile1); $NS1->Spawn (); @@ -98,7 +98,7 @@ $prog = "$startdir/../../Naming_Service/tao_cosnaming"; $NS2 = $test->CreateProcess ("$prog", "$args"); -$test->DeleteFile ("iorfile2"); +$test->DeleteFile ($iorfile2); $NS2->Spawn (); @@ -129,7 +129,7 @@ if ($client != 0) { $NS1->Kill (); $NS2->Kill (); -$test->DeleteFile ("iorfile1"); -$test->DeleteFile ("iorfile2"); +$test->DeleteFile ($iorfile1); +$test->DeleteFile ($iorfile2); exit $status; |