Example #1
0
void
test_octet_seq (const CORBA::Object_var object)
{
  ACE_Sample_History history (niterations);

  Test::octet_load ol (sz);
  ol.length (sz);

  ACE_hrtime_t test_start = ACE_OS::gethrtime ();
  for (int i = 0; i < niterations; ++i)
    {
      ACE_hrtime_t start = ACE_OS::gethrtime ();
      Test::Timestamp start_time = static_cast <Test::Timestamp> (start);

      CORBA::Request_var request =
        object->_request ("test_octet_method");

      request->add_in_arg("octet_load") <<= ol;
      request->add_in_arg("send_time") <<= start_time;

      request->set_return_type (CORBA::_tc_ulonglong);
      request->invoke ();

      ACE_hrtime_t now = ACE_OS::gethrtime ();
      history.sample (now - start);
    }

  ACE_hrtime_t test_end = ACE_OS::gethrtime ();

  ACE_DEBUG ((LM_DEBUG, "test finished\n"));

  ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration...."));
  ACE_High_Res_Timer::global_scale_factor_type gsf =
    ACE_High_Res_Timer::global_scale_factor ();
  ACE_DEBUG ((LM_DEBUG, "done\n"));

  if (do_dump_history)
    {
      history.dump_samples (ACE_TEXT("HISTORY"), gsf);
    }

  ACE_Basic_Stats stats;
  history.collect_basic_stats (stats);
  stats.dump_results (ACE_TEXT("Total"), gsf);

  ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf,
                                         test_end - test_start,
                                         stats.samples_count ());
}
Example #2
0
void
do_primary_test (CORBA::Object_var &server,
                 Messaging::ReplyHandler_var &callback)
{
  try
    {

      CORBA::Request_var req = server->_request("do_forward");

      if (CORBA::is_nil (server.in ()))
        {
          ACE_ERROR ((LM_ERROR,
                      "Object reference <%s> is nil.\n",
                      ior));
          return;
        }

      ACE_DEBUG((LM_DEBUG,"Client sending test string\n"));
      CORBA::String_var test_string = CORBA::string_dup ("123 look at me");
      req->add_in_arg ("text") <<=
        CORBA::Any::from_string(test_string.in(),30);
      req->sendc(callback.in());
    }
  catch (CORBA::Exception &ex)
    {
      ACE_ERROR ((LM_ERROR,
                  "Client caught exception: %C\n",ex._name()));
    }
}
CORBA::Request_ptr createRequest(GenericCmd const& cmd)
{
  CORBA::Request_var req = cmd.reference->_request(cmd.methodName);

  for (CORBA::ULong i = 0; i < cmd.parameters.length(); ++i) {
    switch (cmd.parameters[i].direction) {
      case PARAM_IN: {
        CORBA::Any& a = req->add_in_arg(cmd.parameters[i].name);
        a = cmd.parameters[i].value;
      }
      break;
      case PARAM_OUT: {
        CORBA::Any& a = req->add_out_arg(cmd.parameters[i].name);
        a = cmd.parameters[i].value;
      }
      break;
      case PARAM_INOUT: {
        CORBA::Any& a = req->add_inout_arg(cmd.parameters[i].name);
        a = cmd.parameters[i].value;
      }
      break;
      default:
        MIRO_ASSERT(false);
    }
  }

  req->set_return_type(cmd.returnType);

  CORBA::ExceptionList_ptr e = req->exceptions();
  for (CORBA::ULong i = 0; i < cmd.exceptions.length(); ++i) {
    e->add(cmd.exceptions[i]);
  }

  return req._retn();
}
Example #4
0
File: client.cpp Project: CCJY/ATCD
int
ACE_TMAIN(int argc, ACE_TCHAR *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"));
    }

  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) != 0)
        return 1;

      CORBA::Object_var object =
        orb->string_to_object (ior);

      if (CORBA::is_nil (object.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Nil CORBA::Object reference <%s>\n",
                             ior),
                            1);
        }

      for (int j = 0; j < 100; ++j)
        {
          CORBA::Request_var request =
            object->_request ("test_method");

          CORBA::ULongLong dummy = 0;
          request->add_in_arg("send_time") <<= dummy;

          request->set_return_type (CORBA::_tc_ulonglong);
          request->invoke ();
        }

      ACE_Sample_History history (niterations);

      ACE_hrtime_t test_start = ACE_OS::gethrtime ();
      for (int i = 0; i < niterations; ++i)
        {
          ACE_hrtime_t start = ACE_OS::gethrtime ();

          CORBA::Request_var request =
            object->_request ("test_method");

          CORBA::ULongLong start_time = static_cast <CORBA::ULongLong> (start);
          request->add_in_arg("send_time") <<= start_time;

          request->set_return_type (CORBA::_tc_ulonglong);
          request->invoke ();

          ACE_hrtime_t now = ACE_OS::gethrtime ();
          history.sample (now - start);
        }

      ACE_hrtime_t test_end = ACE_OS::gethrtime ();

      ACE_DEBUG ((LM_DEBUG, "test finished\n"));

      ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration...."));
      ACE_High_Res_Timer::global_scale_factor_type gsf =
        ACE_High_Res_Timer::global_scale_factor ();
      ACE_DEBUG ((LM_DEBUG, "done\n"));

      if (do_dump_history)
        {
          history.dump_samples (ACE_TEXT("HISTORY"), gsf);
        }

      ACE_Basic_Stats stats;
      history.collect_basic_stats (stats);
      stats.dump_results (ACE_TEXT("Total"), gsf);

      ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf,
                                             test_end - test_start,
                                             stats.samples_count ());

      if (do_shutdown)
        {
          CORBA::Request_var request =
            object->_request ("shutdown");

          request->invoke ();

        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}
Example #5
0
int
ACE_TMAIN(int argc, ACE_TCHAR *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"));
    }

  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) != 0)
        return 1;

      CORBA::Object_var object =
        orb->string_to_object (ior);

      if (CORBA::is_nil (object.in ()))
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Nil CORBA::Object reference <%s>\n",
                             ior),
                            1);
        }

      Test::octet_load oc;

      for (int j = 0; j < 100; ++j)
        {
          CORBA::Request_var request =
            object->_request ("test_octet_method");

          Test::Timestamp dummy = 0;
          request->add_in_arg("octet_load") <<= oc;
          request->add_in_arg("send_time") <<= dummy;

          request->set_return_type (CORBA::_tc_ulonglong);
          request->invoke ();
        }

      // Test various sequence types

      if (ACE_OS::strcmp (data_type, ACE_TEXT("octet")) == 0 )
        {
          test_octet_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("char")) == 0)
        {
          test_char_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("long")) == 0)
        {
          test_long_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("short")) == 0)
        {
          test_short_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("double")) == 0)
        {
          test_double_seq (object);
        }
      else if (ACE_OS::strcmp (data_type, ACE_TEXT("longlong")) == 0)
        {
          test_longlong_seq (object);
        }

      if (do_shutdown)
        {
          CORBA::Request_var request =
            object->_request ("shutdown");

          request->invoke ();
        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught:");
      return 1;
    }

  return 0;
}