diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-26 17:27:08 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-26 17:27:08 +0000 |
commit | 5683af2931262cf7c9583894a6dc9b32c5eed631 (patch) | |
tree | 631b031761e5bfe00fd2c479f38d47930a76831e | |
parent | 57dead7253ec896de434eef7dcc356e5d4b7813c (diff) | |
download | ATCD-5683af2931262cf7c9583894a6dc9b32c5eed631.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/performance-tests/POA/Object_Creation_And_Registration/registration.cpp | 316 |
1 files changed, 199 insertions, 117 deletions
diff --git a/TAO/performance-tests/POA/Object_Creation_And_Registration/registration.cpp b/TAO/performance-tests/POA/Object_Creation_And_Registration/registration.cpp index 33fa133383c..8f4dadc1e8b 100644 --- a/TAO/performance-tests/POA/Object_Creation_And_Registration/registration.cpp +++ b/TAO/performance-tests/POA/Object_Creation_And_Registration/registration.cpp @@ -11,7 +11,7 @@ // = DESCRIPTION // // This test is used to measure the time it takes to register and -// activate an object in the POA. +// activate an object in the POA. // // = AUTHOR // Irfan Pyarali @@ -20,6 +20,7 @@ #include "testS.h" #include "ace/Profile_Timer.h" +#include "ace/Get_Opt.h" //#define USING_PURIFY //#define USING_PURIFY_FOR_SERVANT_LOOKUP @@ -37,146 +38,184 @@ class test_i : public POA_test // Prototype for stat printing function void -print_stats (ACE_Profile_Timer::ACE_Elapsed_Time &elapsed_time, - int iterations); +print_stats (ACE_Profile_Timer::ACE_Elapsed_Time &elapsed_time); -int -main (int argc, char **argv) +void +reverse_map_effectiveness (test_i *servants); + +static int measure_reverse_map_effectiveness = 0; + +// Default iterations +static int iterations = 1000; + +static int +parse_args (int argc, char **argv) { - // Default iterations - int iterations = 1000; + ACE_Get_Opt get_opts (argc, argv, "i:r"); + int c; - // Reset iterations if specified by the user. - if (argc > 1) - iterations = atoi (argv[1]); + while ((c = get_opts ()) != -1) + switch (c) + { + case 'i': + iterations = ACE_OS::atoi (get_opts.optarg); + break; - // Initialize the ORB first. - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0); + case 'r': + measure_reverse_map_effectiveness = 1; + break; - // Obtain the RootPOA. - CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "[-r [measure reverse map effectiveness]] " + "[-i iterations] " + "\n", + argv [0]), + -1); + } - // Get the POA_var object from Object_var. - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (obj.in ()); + // Indicates successful parsing of command line. + return 0; +} - // Create an array of servants - test_i *servants = new test_i[iterations]; - - // Create an array of objects - test_var *objects = new test_var[iterations]; +int +main (int argc, char **argv) +{ + ACE_DECLARE_NEW_CORBA_ENV; - // Create an array of objects - PortableServer::ObjectId_var *object_ids = new PortableServer::ObjectId_var[iterations]; + ACE_TRY + { + // Initialize the ORB first. + CORBA::ORB_var orb = CORBA::ORB_init (argc, + argv, + 0, + ACE_TRY_ENV); + ACE_TRY_CHECK; - // Size of the active object map - u_long active_object_map_size = TAO_ORB_Core_instance ()->server_factory ()->active_object_map_size (); + int result = parse_args (argc, argv); + if (result != 0) + return result; - // Hash counters - u_long *hash_counter = new u_long[active_object_map_size]; + // Obtain the RootPOA. + CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA", + ACE_TRY_ENV); + ACE_TRY_CHECK; - // Index counter - int i = 0; + // Get the POA_var object from Object_var. + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (obj.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; - // Initialize the hash counters - for (i = 0; i < active_object_map_size; i++) - { - hash_counter[i] = 0; - } + // Create an array of servants + test_i *servants = new test_i[iterations]; - // Calculate the effectiveness of the hash. - for (i = 0; i < iterations; i++) - { - u_long hash_index = u_long (&servants[i]) % active_object_map_size; - hash_counter[hash_index]++; - } + // Create an array of objects + test_var *objects = new test_var[iterations]; - for (i = 0; i < active_object_map_size; i++) - { - if (((i) % 10) == 0) + // Create an array of objects + PortableServer::ObjectId_var *object_ids = new PortableServer::ObjectId_var[iterations]; + + if (measure_reverse_map_effectiveness) { - ACE_DEBUG ((LM_DEBUG, "\n")); + reverse_map_effectiveness (servants); } - ACE_DEBUG ((LM_DEBUG, "%d = %d, ", i, hash_counter[i])); - } - ACE_DEBUG ((LM_DEBUG, "\n\n")); - { - // Profile timer - ACE_Profile_Timer timer; - ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time; - - // We start the profile timer here... - timer.start (); - + // Index counter + int i = 0; + + { + // Profile timer + ACE_Profile_Timer timer; + ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time; + + // We start the profile timer here... + timer.start (); + #if defined (USING_PURIFY_FOR_UNDERBAR_THIS) - // Reset Quantify data recording; whatever happened in the past is - // not relevant to this test. - QuantifyClearData (); - QuantifyStartRecordingData (); + // Reset Quantify data recording; whatever happened in the + // past is not relevant to this test. + QuantifyClearData (); + QuantifyStartRecordingData (); #endif /* USING_PURIFY_FOR_UNDERBAR_THIS */ - - for (i = 0; i < iterations; i++) - { - objects[i] = servants[i]._this (); - } - + + for (i = 0; i < iterations; i++) + { + objects[i] = servants[i]._this (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + #if defined (USING_PURIFY_FOR_UNDERBAR_THIS) - // Stop recording data here; whatever happens after this in the test - // is not relevant to this test. - QuantifyStopRecordingData (); + // Stop recording data here; whatever happens after this in + // the test is not relevant to this test. + QuantifyStopRecordingData (); #endif /* USING_PURIFY_FOR_UNDERBAR_THIS */ - - // stop the timer. - timer.stop (); - timer.elapsed_time (elapsed_time); - - // compute average time. - print_stats (elapsed_time, i); - } - - { - // Profile timer - ACE_Profile_Timer timer; - ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time; - - // We start the profile timer here... - timer.start (); - + + // stop the timer. + timer.stop (); + timer.elapsed_time (elapsed_time); + + // compute average time. + ACE_DEBUG ((LM_DEBUG, "\n_this stats...\n")); + print_stats (elapsed_time); + } + + { + // Profile timer + ACE_Profile_Timer timer; + ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time; + + // We start the profile timer here... + timer.start (); + #if defined (USING_PURIFY_FOR_SERVANT_LOOKUP) - // Reset Quantify data recording; whatever happened in the past is - // not relevant to this test. - QuantifyClearData (); - QuantifyStartRecordingData (); + // Reset Quantify data recording; whatever happened in the + // past is not relevant to this test. + QuantifyClearData (); + QuantifyStartRecordingData (); #endif /* USING_PURIFY_FOR_SERVANT_LOOKUP */ - - for (i = 0; i < iterations; i++) - { - object_ids[i] = root_poa->servant_to_id (&servants[i]); - } - + + for (i = 0; i < iterations; i++) + { + object_ids[i] = root_poa->servant_to_id (&servants[i], + ACE_TRY_ENV); + ACE_TRY_CHECK; + } + #if defined (USING_PURIFY_FOR_SERVANT_LOOKUP) - // Stop recording data here; whatever happens after this in the test - // is not relevant to this test. - QuantifyStopRecordingData (); + // Stop recording data here; whatever happens after this in + // the test is not relevant to this test. + QuantifyStopRecordingData (); #endif /* USING_PURIFY_FOR_SERVANT_LOOKUP */ - - // stop the timer. - timer.stop (); - timer.elapsed_time (elapsed_time); - - // compute average time. - print_stats (elapsed_time, i); - } - - // Cleanup - delete[] objects; - delete[] servants; - delete[] hash_counter; - // Destroy RootPOA. - root_poa->destroy (1, - 1); + // stop the timer. + timer.stop (); + timer.elapsed_time (elapsed_time); + + // compute average time. + ACE_DEBUG ((LM_DEBUG, "\nservant_to_id stats...\n")); + print_stats (elapsed_time); + } + + // Destroy RootPOA. + root_poa->destroy (1, + 1, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // Cleanup + delete[] objects; + delete[] servants; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught"); + return -1; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (-1); return 0; } @@ -185,8 +224,7 @@ main (int argc, char **argv) // Code for printing stats // void -print_stats (ACE_Profile_Timer::ACE_Elapsed_Time &elapsed_time, - int iterations) +print_stats (ACE_Profile_Timer::ACE_Elapsed_Time &elapsed_time) { if (iterations > 0) { @@ -217,3 +255,47 @@ print_stats (ACE_Profile_Timer::ACE_Elapsed_Time &elapsed_time, "\tNo time stats printed. Zero iterations or error ocurred.\n")); } + +// +// Measures how well the reverse hash map works. +// +void +reverse_map_effectiveness (test_i *servants) +{ + // Size of the active object map + const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters ¶meters = + TAO_ORB_Core_instance ()->server_factory ()->active_object_map_creation_parameters (); + + u_long active_object_map_size = parameters.active_object_map_size_; + + // Hash counters + u_long *hash_counter = new u_long[active_object_map_size]; + + // Index counter + int i = 0; + + // Initialize the hash counters + for (i = 0; i < active_object_map_size; i++) + { + hash_counter[i] = 0; + } + + // Calculate the effectiveness of the hash. + for (i = 0; i < iterations; i++) + { + u_long hash_index = u_long (&servants[i]) % active_object_map_size; + hash_counter[hash_index]++; + } + + for (i = 0; i < active_object_map_size; i++) + { + if (((i) % 10) == 0) + { + ACE_DEBUG ((LM_DEBUG, "\n")); + } + ACE_DEBUG ((LM_DEBUG, "%d = %d, ", i, hash_counter[i])); + } + ACE_DEBUG ((LM_DEBUG, "\n\n")); + + delete[] hash_counter; +} |