diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-30 00:50:56 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-30 00:50:56 +0000 |
commit | 1a7abc19d9011c21f9c1d66681a8906ab60b9571 (patch) | |
tree | 4a60169abc31b31ebfe948456a061dbac725cde1 /TAO/performance-tests/Thruput | |
parent | daa6fdda8fb9592855e612c43b5deecf59209e8e (diff) | |
download | ATCD-1a7abc19d9011c21f9c1d66681a8906ab60b9571.tar.gz |
ChangeLogTag:Tue Jun 29 19:48:33 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'TAO/performance-tests/Thruput')
-rw-r--r-- | TAO/performance-tests/Thruput/TAO/client.cpp | 212 | ||||
-rw-r--r-- | TAO/performance-tests/Thruput/TAO/server.cpp | 263 |
2 files changed, 218 insertions, 257 deletions
diff --git a/TAO/performance-tests/Thruput/TAO/client.cpp b/TAO/performance-tests/Thruput/TAO/client.cpp index c6cfd7d25d9..a2e599fd155 100644 --- a/TAO/performance-tests/Thruput/TAO/client.cpp +++ b/TAO/performance-tests/Thruput/TAO/client.cpp @@ -76,16 +76,12 @@ main (int argc, char *argv[]) int c; CORBA::ORB_ptr orb_ptr; // underlying ORB - const char* objkey = "TTCP_IIOP_test"; // name of the TTCP object on the // server CORBA::Object_ptr objref = CORBA::Object::_nil(); // object reference ttcp_sequence_ptr ttcp_seq = 0; // obj reference to TTCP object - CORBA::Environment env; // environment - - ACE_UNUSED_ARG (objkey); // parse the arguments - ACE_Get_Opt get_opt (argc, argv, "d:vm:l:L:S:q:i:f:"); // Command line options + ACE_Get_Opt get_opt (argc, argv, "d:vm:l:L:S:q:i:f:"); TAO_debug_level = 0; while ((c = get_opt ()) != -1) { @@ -147,114 +143,103 @@ main (int argc, char *argv[]) } } - // - // Transmitter - // - - // get a handle to the ORB - orb_ptr = CORBA::ORB_init (argc, argv, "internet", env); - if (env.exception () != 0) + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY { - env.print_exception ("ORB initialization", stdout); - return -1; - } + // + // Transmitter + // + + // get a handle to the ORB + orb_ptr = CORBA::ORB_init (argc, argv, "internet", ACE_TRY_ENV); + ACE_TRY_CHECK; - ACE_DEBUG ((LM_DEBUG, "Read IOR string as: %s\n" , ior)); - - // retrieve an object reference out of the stringified IOR - objref = orb_ptr->string_to_object (ior, env); - - if (env.exception () != 0) - { - env.print_exception ("string_to_object", stdout); - return -1; - } + ACE_DEBUG ((LM_DEBUG, "Read IOR string as: %s\n" , ior)); - if (!CORBA::is_nil (objref)) - { - // if it is a valid obj ref, narrow it to a ttcp_sequence CORBA object - ttcp_seq = ttcp_sequence::_narrow (objref, env); - if (env.exception () != 0) - { - env.print_exception ("ttcp_sequence::_narrow"); - return -1; - } + // retrieve an object reference out of the stringified IOR + objref = orb_ptr->string_to_object (ior, ACE_TRY_ENV); + ACE_TRY_CHECK; - if (!CORBA::is_nil (ttcp_seq)) + if (!CORBA::is_nil (objref)) { + // if it is a valid obj ref, narrow it to a ttcp_sequence + // CORBA object + ttcp_seq = ttcp_sequence::_narrow (objref, ACE_TRY_ENV); + ACE_TRY_CHECK; - // the number of iterations is based on the total data size and the - // individual buffer size sent - nbuf = srcDataSize/buflen; - ACE_DEBUG ((LM_DEBUG, "data size = %d, buflen = %d, nbuf = %d\n", - srcDataSize, buflen, nbuf)); - - // - // Prepare the Message to be sent - // - - - // first allocate a buffer of the desired size and alignment - errno = 0; - if ((buf = (char *) ACE_OS::malloc (buflen)) == (char *) NULL) - err ("malloc"); - - // fill the buffer with the data type to be sent - FillPattern (buf, buflen, dt); - - // - // Start the timers on the client and server sides - // - - prep_timer (); // start our time - env.clear (); - ttcp_seq->start_timer (env); // ask the server to start its timer - if (env.exception () != 0) + if (!CORBA::is_nil (ttcp_seq)) { - env.print_exception ("start_timer operation", stdout); - return -1; - } + // the number of iterations is based on the total data size and the + // individual buffer size sent + nbuf = srcDataSize/buflen; + ACE_DEBUG ((LM_DEBUG, "data size = %d, buflen = %d, nbuf = %d\n", + srcDataSize, buflen, nbuf)); + + // + // Prepare the Message to be sent + // + + + // first allocate a buffer of the desired size and alignment + errno = 0; + if ((buf = (char *) ACE_OS::malloc (buflen)) == (char *) NULL) + err ("malloc"); + + // fill the buffer with the data type to be sent + FillPattern (buf, buflen, dt); + + // + // Start the timers on the client and server sides + // + + prep_timer (); // start our time + // ask the server to start its timer + ttcp_seq->start_timer (ACE_TRY_ENV); + ACE_TRY_CHECK; #if defined (ACE_HAS_QUANTIFY) - /* start recording quantify data from here */ - quantify_clear_data (); - quantify_start_recording_data (); + /* start recording quantify data from here */ + quantify_clear_data (); + quantify_start_recording_data (); #endif /* ACE_HAS_QUANTIFY */ - // send the same buffer nbuf times - while (nbuf--) - { - switch (dt){ - case SEND_SHORT: - ttcp_seq->sendShortSeq (*sseq, env); - nbytes += sseq->length () * sizeof (CORBA::Short); - break; - case SEND_LONG: - ttcp_seq->sendLongSeq (*lseq, env); - nbytes += lseq->length () * sizeof (CORBA::Long); - break; - case SEND_OCTET: - ttcp_seq->sendOctetSeq (*oseq, env); - nbytes += oseq->length () * sizeof (CORBA::Octet); - break; - case SEND_DOUBLE: - ttcp_seq->sendDoubleSeq (*dseq, env); - nbytes += dseq->length () * sizeof (CORBA::Double); - break; - case SEND_CHAR: - ttcp_seq->sendCharSeq (*cseq, env); - nbytes += cseq->length () * sizeof (CORBA::Char); - break; - case SEND_STRUCT: - ttcp_seq->sendStructSeq (*Sseq, env); - nbytes += Sseq->length () * sizeof (BinStruct); - break; - } - numCalls++; // nbytes and numCalls are used in the thruput - // measurement - if (env.exception () != 0) + // send the same buffer nbuf times + while (nbuf--) { - env.print_exception ("send operation", stdout); - return -1; + switch (dt) + { + case SEND_SHORT: + ttcp_seq->sendShortSeq (*sseq, ACE_TRY_ENV); + ACE_TRY_CHECK; + nbytes += sseq->length () * sizeof (CORBA::Short); + break; + case SEND_LONG: + ttcp_seq->sendLongSeq (*lseq, ACE_TRY_ENV); + ACE_TRY_CHECK; + nbytes += lseq->length () * sizeof (CORBA::Long); + break; + case SEND_OCTET: + ttcp_seq->sendOctetSeq (*oseq, ACE_TRY_ENV); + ACE_TRY_CHECK; + nbytes += oseq->length () * sizeof (CORBA::Octet); + break; + case SEND_DOUBLE: + ttcp_seq->sendDoubleSeq (*dseq, ACE_TRY_ENV); + ACE_TRY_CHECK; + nbytes += dseq->length () * sizeof (CORBA::Double); + break; + case SEND_CHAR: + ttcp_seq->sendCharSeq (*cseq, ACE_TRY_ENV); + ACE_TRY_CHECK; + nbytes += cseq->length () * sizeof (CORBA::Char); + break; + case SEND_STRUCT: + ttcp_seq->sendStructSeq (*Sseq, ACE_TRY_ENV); + ACE_TRY_CHECK; + nbytes += Sseq->length () * sizeof (BinStruct); + break; + } + numCalls++; // nbytes and numCalls are used in the thruput + // measurement } } #if defined (ACE_HAS_QUANTIFY) @@ -264,24 +249,27 @@ main (int argc, char *argv[]) // Stop the timer // // stop the timer on the server side - ttcp_seq->stop_timer (env); - if (env.exception () != 0) - { - env.print_exception ("stop_timer operation", stdout); - return -1; - } + ttcp_seq->stop_timer (ACE_TRY_ENV); + // stop our timer (void) read_timer (stats, sizeof (stats)); // print results PrintStats(); } + + CORBA::release (ttcp_seq); + CORBA::release (objref); + CORBA::release (orb_ptr); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "client"); + return -1; } + ACE_ENDTRY; - CORBA::release (ttcp_seq); - CORBA::release (objref); - CORBA::release (orb_ptr); - return (0); + return 0; } int print_usage (void) diff --git a/TAO/performance-tests/Thruput/TAO/server.cpp b/TAO/performance-tests/Thruput/TAO/server.cpp index ef9dade18aa..62f593b0683 100644 --- a/TAO/performance-tests/Thruput/TAO/server.cpp +++ b/TAO/performance-tests/Thruput/TAO/server.cpp @@ -67,168 +67,141 @@ main (int argc, char **argv) { int c; // option - CORBA::Environment env; // environment CORBA::ORB_var orb_var; // handle to the ORB PortableServer::POA_var root_poa; // Object adapter - CORBA::String key = (CORBA::String) "key0"; // key assigned to our - // target object CORBA::Object_var obj_var; const char *oa_name = "RootPOA"; // name of our OA const char *orb_name = "internet"; // name of our ORB CORBA::String str; // for stringified representation of the object reference FILE *ior_file = 0; - ACE_UNUSED_ARG (key); - // initialize the underlying ORB and get a handle to it - orb_var = CORBA::ORB_init (argc, argv, orb_name, env); - if (env.exception () != 0) - { - env.print_exception ("ORB init"); - return 1; - } - - obj_var = orb_var->resolve_initial_references(oa_name); - - if (CORBA::is_nil(obj_var.in())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to initialize the POA.\n"), - -1); - - root_poa = PortableServer::POA::_narrow (obj_var.in (), env); - - if (env.exception () != 0) + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY { - env.print_exception ("POA init"); - return 1; - } - - PortableServer::POAManager_var poa_manager = - root_poa->the_POAManager (env); - - if (env.exception () != 0) - { - env.print_exception ("POA manager"); - return 1; - } - - CORBA::PolicyList policies (2); - policies.length (2); - policies[0] = - root_poa->create_id_assignment_policy (PortableServer::USER_ID, - env); - policies[1] = - root_poa->create_lifespan_policy (PortableServer::PERSISTENT, - env); - - // We use a different POA, otherwise the user would have to - // change the object key each time it invokes the server. - PortableServer::POA_var good_poa = - root_poa->create_POA ("child_poa", - poa_manager.in (), - policies, - env); - - if (env.exception () != 0) - { - env.print_exception ("create good poa"); - return 1; - } - - // for parsing the arguments - ACE_Get_Opt get_opt (argc, argv, "l:vd:f:L:o:"); - - TAO_debug_level = 0; - for (; (c = get_opt ()) != EOF;) - { - switch (c) + orb_var = CORBA::ORB_init (argc, argv, orb_name, ACE_TRY_ENV); + ACE_TRY_CHECK; + + obj_var = orb_var->resolve_initial_references(oa_name, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (CORBA::is_nil(obj_var.in())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + -1); + + root_poa = PortableServer::POA::_narrow (obj_var.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_TRY_ENV); + ACE_TRY_CHECK; + + CORBA::PolicyList policies (2); + policies.length (2); + policies[0] = + root_poa->create_id_assignment_policy (PortableServer::USER_ID, + ACE_TRY_ENV); + ACE_TRY_CHECK; + policies[1] = + root_poa->create_lifespan_policy (PortableServer::PERSISTENT, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // We use a different POA, otherwise the user would have to + // change the object key each time it invokes the server. + PortableServer::POA_var good_poa = + root_poa->create_POA ("child_poa", + poa_manager.in (), + policies, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + // for parsing the arguments + ACE_Get_Opt get_opt (argc, argv, "l:vd:f:L:o:"); + + TAO_debug_level = 0; + for (; (c = get_opt ()) != EOF;) { - case 'L': - // title of output file that stores result - title = ACE_OS::strdup (get_opt.optarg); - break; - case 'd': - // debugging level - TAO_debug_level = ACE_OS::atoi (get_opt.optarg); - if (TAO_debug_level > 10) - TAO_debug_level = 10; - break; - case 'f': - // output format i.e., Mbps, Kbps, etc - fmt = *get_opt.optarg; - break; - case 'o': - ior_file = ACE_OS::fopen (get_opt.optarg,"w"); - ACE_DEBUG ((LM_DEBUG,"ior_file is %s\n",get_opt.optarg)); - break; + switch (c) + { + case 'L': + // title of output file that stores result + title = ACE_OS::strdup (get_opt.optarg); + break; + case 'd': + // debugging level + TAO_debug_level = ACE_OS::atoi (get_opt.optarg); + if (TAO_debug_level > 10) + TAO_debug_level = 10; + break; + case 'f': + // output format i.e., Mbps, Kbps, etc + fmt = *get_opt.optarg; + break; + case 'o': + ior_file = ACE_OS::fopen (get_opt.optarg,"w"); + ACE_DEBUG ((LM_DEBUG,"ior_file is %s\n",get_opt.optarg)); + break; + } + } + + // + // Receiver + // + + // create an instance of an object implementing the "ttcp" interface + my_ttcp = new ttcp_sequence_i; // this is its name + + PortableServer::ObjectId_var id = + PortableServer::string_to_ObjectId ("TTCP_IIOP_test"); + good_poa->activate_object_with_id (id.in (), + my_ttcp, + ACE_TRY_ENV); + ACE_TRY_CHECK; + + obj_var = good_poa->id_to_reference (id.in (), ACE_TRY_ENV); + ACE_TRY_CHECK; + + poa_manager->activate (ACE_TRY_ENV); + ACE_TRY_CHECK; + + // get a stringified representation of the object reference + // created above + str = orb_var->object_to_string (obj_var.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, "stringified obj reference = %s\n", str)); + } + + if (ior_file != 0) + { + // write ior to a file + ACE_OS::fprintf (ior_file,"%s",str); + ACE_OS::fclose (ior_file); } - } - - // - // Receiver - // - - // create an instance of an object implementing the "ttcp" interface - my_ttcp = new ttcp_sequence_i; // this is its name - - PortableServer::ObjectId_var id = - PortableServer::string_to_ObjectId ("TTCP_IIOP_test"); - good_poa->activate_object_with_id (id.in (), - my_ttcp, - env); - if (env.exception () != 0) - { - env.print_exception ("string_to_ObjectId"); - return 1; - } - - obj_var = good_poa->id_to_reference (id.in (), env); - - if (env.exception () != 0) - { - env.print_exception ("id_to_reference"); - return 1; - } - - poa_manager->activate (env); - if (env.exception () != 0) - { - env.print_exception ("id_to_reference"); - return 1; +#if defined (ACE_HAS_QUANTIFY) + // gather profile data + quantify_clear_data(); + quantify_start_recording_data(); +#endif /* ACE_HAS_QUANTIFY */ + + // Handle requests for this object until we're killed, or one of the + // methods asks us to exit. + if (orb_var->run () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "run"), -1); } - - // get a stringified representation of the object reference created above - str = orb_var->object_to_string (obj_var.in (), - env); - if (env.exception () != 0) + ACE_CATCHANY { - env.print_exception ("object_to_string"); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "server"); return 1; } - - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, "stringified obj reference = %s\n", str)); - } - - if (ior_file != 0) - { - // write ior to a file - ACE_OS::fprintf (ior_file,"%s",str); - ACE_OS::fclose (ior_file); - } - -#if defined (ACE_HAS_QUANTIFY) - // gather profile data - quantify_clear_data(); - quantify_start_recording_data(); -#endif /* ACE_HAS_QUANTIFY */ - - // Handle requests for this object until we're killed, or one of the - // methods asks us to exit. - if (orb_var->run () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "run"), -1); + ACE_ENDTRY; return 0; } |