Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / performance-tests / Memory / Single_Threaded / client.cpp
blobc6d5c2e11f7a8ce7d9d1446efc7938f3d5241bc8
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
5 static int n = 100;
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:n:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'n':
16 n = ACE_OS::atoi (get_opts.opt_arg ());
17 break;
19 case 'k':
20 ior = get_opts.opt_arg ();
21 break;
23 case '?':
24 default:
25 ACE_ERROR_RETURN ((LM_ERROR,
26 "usage: %s "
27 "-k <ior> "
28 "\n",
29 argv [0]),
30 -1);
32 // Indicates successful parsing of the command line
33 return 0;
36 int
37 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
39 try
41 CORBA::ORB_var orb =
42 CORBA::ORB_init (argc, argv);
44 if (parse_args (argc, argv) != 0)
45 return 1;
47 CORBA::Object_var tmp =
48 orb->string_to_object(ior);
50 Test::Memory_Growth_var mem =
51 Test::Memory_Growth::_narrow(tmp.in ());
53 if (CORBA::is_nil (mem.in ()))
55 ACE_ERROR_RETURN ((LM_DEBUG,
56 "Nil Test::Hello reference <%s>\n",
57 ior),
58 1);
61 // Make a few calls to the remote object
62 for (int iter = 0; iter != n; iter++)
64 mem->ping ();
67 // Let us run the event loop. This way we will not exit
68 orb->run ();
70 catch (const CORBA::Exception& ex)
72 ex._tao_print_exception ("Exception caught:");
73 return 1;
76 return 0;