Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / DSI_AMH / client.cpp
bloba1961296db0aba502aded8207931da994ae213e9
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/High_Res_Timer.h"
4 #include "tao/debug.h"
6 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
7 int niterations = 100;
8 int do_shutdown = 1;
10 int
11 parse_args (int argc, ACE_TCHAR *argv[])
13 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xk:i:"));
14 int c;
16 while ((c = get_opts ()) != -1)
17 switch (c)
19 case 'x':
20 do_shutdown = 0;
21 break;
23 case 'k':
24 ior = get_opts.opt_arg ();
25 break;
27 case 'i':
28 niterations = ACE_OS::atoi (get_opts.opt_arg ());
29 break;
31 case '?':
32 default:
33 ACE_ERROR_RETURN ((LM_ERROR,
34 "usage: %s "
35 "-k <ior> "
36 "-i <niterations> "
37 "-x (disable shutdown) "
38 "\n",
39 argv [0]),
40 -1);
42 // Indicates successful parsing of the command line
43 return 0;
46 int
47 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
49 try
51 CORBA::ORB_var orb =
52 CORBA::ORB_init (argc, argv);
54 if (parse_args (argc, argv) != 0)
55 return 1;
57 CORBA::Object_var object =
58 orb->string_to_object (ior);
60 Test::Roundtrip_var roundtrip =
61 Test::Roundtrip::_narrow (object.in ());
63 if (CORBA::is_nil (roundtrip.in ()))
65 ACE_ERROR_RETURN ((LM_ERROR,
66 "Nil Test::Roundtrip reference <%s>\n",
67 ior),
68 1);
71 for (int i = 0; i < niterations; ++i)
73 ACE_hrtime_t start = ACE_OS::gethrtime ();
74 ACE_hrtime_t retval = roundtrip->test_method (start);
76 if (TAO_debug_level > 0)
77 ACE_DEBUG ((LM_DEBUG, "test return value: %Q\n", retval));
81 ACE_DEBUG ((LM_DEBUG, "test finished\n"));
84 if (do_shutdown)
86 roundtrip->shutdown ();
89 catch (const CORBA::Exception& ex)
91 ex._tao_print_exception ("Exception caught:");
92 return 1;
95 return 0;