From 56681ffa90714cf82c32e907c0f80cea75166740 Mon Sep 17 00:00:00 2001 From: okellogg Date: Tue, 29 Jan 2002 20:21:11 +0000 Subject: ChangeLogTag:Tue Jan 29 21:09:12 2002 Oliver Kellogg --- .../Deferred_Latency/Roundtrip.cpp | 26 +++ TAO/performance-tests/Deferred_Latency/Roundtrip.h | 46 +++++ TAO/performance-tests/Deferred_Latency/client.cpp | 203 +++++++++++++++++++++ TAO/performance-tests/Deferred_Latency/server.cpp | 136 ++++++++++++++ 4 files changed, 411 insertions(+) create mode 100644 TAO/performance-tests/Deferred_Latency/Roundtrip.cpp create mode 100644 TAO/performance-tests/Deferred_Latency/Roundtrip.h create mode 100644 TAO/performance-tests/Deferred_Latency/client.cpp create mode 100644 TAO/performance-tests/Deferred_Latency/server.cpp (limited to 'TAO/performance-tests/Deferred_Latency') diff --git a/TAO/performance-tests/Deferred_Latency/Roundtrip.cpp b/TAO/performance-tests/Deferred_Latency/Roundtrip.cpp new file mode 100644 index 00000000000..72f83576b44 --- /dev/null +++ b/TAO/performance-tests/Deferred_Latency/Roundtrip.cpp @@ -0,0 +1,26 @@ +// +// $Id$ +// +#include "Roundtrip.h" + +ACE_RCSID(Single_Threaded_Latency, Roundtrip, "$Id$") + +Roundtrip::Roundtrip (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +Test::Timestamp +Roundtrip::test_method (Test::Timestamp send_time + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return send_time; +} + +void +Roundtrip::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/performance-tests/Deferred_Latency/Roundtrip.h b/TAO/performance-tests/Deferred_Latency/Roundtrip.h new file mode 100644 index 00000000000..efef33dd7e6 --- /dev/null +++ b/TAO/performance-tests/Deferred_Latency/Roundtrip.h @@ -0,0 +1,46 @@ +// +// $Id$ +// + +#ifndef ROUNDTRIP_H +#define ROUNDTRIP_H +#include "ace/pre.h" + +#include "TestS.h" + +#if defined (_MSC_VER) +# if (_MSC_VER >= 1200) +# pragma warning(push) +# endif /* _MSC_VER >= 1200 */ +# pragma warning (disable:4250) +#endif /* _MSC_VER */ + +/// Implement the Test::Roundtrip interface +class Roundtrip + : public virtual POA_Test::Roundtrip + , public virtual PortableServer::RefCountServantBase +{ +public: + /// Constructor + Roundtrip (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual Test::Timestamp test_method (Test::Timestamp send_time + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + /// Use an ORB reference to conver strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma warning(pop) +#endif /* _MSC_VER */ + +#include "ace/post.h" +#endif /* ROUNDTRIP_H */ diff --git a/TAO/performance-tests/Deferred_Latency/client.cpp b/TAO/performance-tests/Deferred_Latency/client.cpp new file mode 100644 index 00000000000..8aa94d94172 --- /dev/null +++ b/TAO/performance-tests/Deferred_Latency/client.cpp @@ -0,0 +1,203 @@ +// $Id$ + +#include "TestC.h" + +#include "tao/DynamicInterface/Request.h" + +#include "tao/Strategies/advanced_resource.h" + +#include "ace/Get_Opt.h" +#include "ace/Sched_Params.h" +#include "ace/High_Res_Timer.h" +#include "ace/Sched_Params.h" +#include "ace/Stats.h" +#include "ace/Sample_History.h" + +ACE_RCSID(Deferred_Latency, client, "$Id$") + +const char *ior = "file://test.ior"; +int niterations = 1000; +int burst = 10; +int do_shutdown = 1; +int do_dump_history = 0; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "hxk:i:b:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'h': + do_dump_history = 1; + break; + + case 'x': + do_shutdown = 0; + break; + + case 'k': + ior = get_opts.opt_arg (); + break; + + case 'i': + niterations = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'b': + burst = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k " + "-i " + "-b " + "-x (disable shutdown) " + "-h (dump history) " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + int priority = + (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; + // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. + + if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, + priority, + ACE_SCOPE_PROCESS)) != 0) + { + if (ACE_OS::last_error () == EPERM) + { + ACE_DEBUG ((LM_DEBUG, + "client (%P|%t): user is not superuser, " + "test runs in time-shared class\n")); + } + else + ACE_ERROR ((LM_ERROR, + "client (%P|%t): sched_params failed\n")); + } + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var object = + orb->string_to_object (ior ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Test::Roundtrip_var roundtrip = + Test::Roundtrip::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (roundtrip.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Nil Test::Roundtrip reference <%s>\n", + ior), + 1); + } + + for (int j = 0; j < 100; ++j) + { + ACE_hrtime_t start = 0; + (void) roundtrip->test_method (start ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + ACE_Sample_History history (niterations); + + ACE_hrtime_t test_start = ACE_OS::gethrtime (); + + CORBA::Request_var *request; + ACE_NEW_RETURN (request, CORBA::Request_var[burst], 1); + + for (int i = 0; i < niterations; ++i) + { + int j; + + for (j = 0; j != burst; ++j) + { + CORBA::ULongLong start = ACE_OS::gethrtime (); + + request[j] = + roundtrip->_request ("test_method" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + request[j]->add_in_arg () <<= start; + request[j]->set_return_type (CORBA::_tc_ulonglong); + + request[j]->send_deferred (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + for (j = 0; j != burst; ++j) + { + request[j]->get_response (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ULongLong retval; + if ((request[j]->return_value () >>= retval) == 1) + { + ACE_hrtime_t now = ACE_OS::gethrtime (); + history.sample (now - retval); + } + } + } + delete[] request; + + ACE_hrtime_t test_end = ACE_OS::gethrtime (); + + ACE_DEBUG ((LM_DEBUG, "test finished\n")); + + ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration....")); + ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor (); + ACE_DEBUG ((LM_DEBUG, "done\n")); + + if (do_dump_history) + { + history.dump_samples ("HISTORY", gsf); + } + + ACE_Basic_Stats stats; + history.collect_basic_stats (stats); + stats.dump_results ("Total", gsf); + + ACE_Throughput_Stats::dump_throughput ("Total", gsf, + test_end - test_start, + stats.samples_count ()); + + if (do_shutdown) + { + roundtrip->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Caught exception:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/performance-tests/Deferred_Latency/server.cpp b/TAO/performance-tests/Deferred_Latency/server.cpp new file mode 100644 index 00000000000..e96f0ff595a --- /dev/null +++ b/TAO/performance-tests/Deferred_Latency/server.cpp @@ -0,0 +1,136 @@ +// $Id$ + +#include "Roundtrip.h" +#include "ace/Get_Opt.h" +#include "ace/Sched_Params.h" + +#include "tao/Strategies/advanced_resource.h" + +ACE_RCSID(Single_Threaded_Latency, server, "$Id$") + +const char *ior_output_file = "test.ior"; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.opt_arg (); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + int priority = + (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; + priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, + priority); + // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. + + if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, + priority, + ACE_SCOPE_PROCESS)) != 0) + { + if (ACE_OS::last_error () == EPERM) + { + ACE_DEBUG ((LM_DEBUG, + "server (%P|%t): user is not superuser, " + "test runs in time-shared class\n")); + } + else + ACE_ERROR ((LM_ERROR, + "server (%P|%t): sched_params failed\n")); + } + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to initialize the POA.\n"), + 1); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + Roundtrip *roundtrip_impl; + ACE_NEW_RETURN (roundtrip_impl, + Roundtrip (orb.in ()), + 1); + PortableServer::ServantBase_var owner_transfer(roundtrip_impl); + + Test::Roundtrip_var roundtrip = + roundtrip_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (roundtrip.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // If the ior_output_file exists, output the ior to it + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); + + root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} -- cgit v1.2.1