Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / performance-tests / Memory / IORsize / client.cpp
blob2f0978123098ec9ca32f620b4c984da16e16de54
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
3 #include "TestS.h"
4 #include "Foo_i.h"
6 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
7 static int n = 10;
8 int
9 parse_args (int argc, ACE_TCHAR *argv[])
11 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:n:"));
12 int c;
14 while ((c = get_opts ()) != -1)
15 switch (c)
17 case 'n':
18 n = ACE_OS::atoi (get_opts.opt_arg ());
19 break;
21 case 'k':
22 ior = get_opts.opt_arg ();
23 break;
25 case '?':
26 default:
27 ACE_ERROR_RETURN ((LM_ERROR,
28 "usage: %s "
29 "-k <ior> "
30 "\n",
31 argv [0]),
32 -1);
34 // Indicates successful parsing of the command line
35 return 0;
38 int
39 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
41 try
43 CORBA::ORB_var orb =
44 CORBA::ORB_init (argc, argv);
46 CORBA::Object_var poa_object =
47 orb->resolve_initial_references("RootPOA");
49 PortableServer::POA_var root_poa =
50 PortableServer::POA::_narrow (poa_object.in ());
52 if (parse_args (argc, argv) != 0)
53 return 1;
55 Foo_i *foo_i;
56 ACE_NEW_RETURN (foo_i,
57 Foo_i (orb.in ()),
58 1);
60 PortableServer::ServantBase_var owner_transfer(foo_i);
62 Test::Foo_var foo =
63 foo_i->_this ();
65 CORBA::Object_var tmp =
66 orb->string_to_object(ior);
68 Test::Memory_Growth_var mem =
69 Test::Memory_Growth::_narrow(tmp.in ());
71 if (CORBA::is_nil (mem.in ()))
73 ACE_ERROR_RETURN ((LM_DEBUG,
74 "Nil Test::Hello reference <%s>\n",
75 ior),
76 1);
79 // Make a sequence..
80 Test::PayLoad pl (50000);
81 pl.length (50000);
83 for (CORBA::ULong l = 0;
84 l != pl.length ();
85 l++)
87 pl[l] = foo;
90 // Make a few calls to the remote object
91 for (int iter = 0; iter != n; iter++)
93 mem->send_objref (pl);
96 // Let us run the event loop. This way we will not exit
97 orb->run ();
99 catch (const CORBA::Exception& ex)
101 ex._tao_print_exception ("Exception caught:");
102 return 1;
105 return 0;