Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / performance-tests / RPC / client.cpp
blob5481f7740540508227acaa32d0ebf2416d12a730
1 #include "ace/Stats.h"
2 #include "ace/High_Res_Timer.h"
3 #include "ace/Get_Opt.h"
4 #include "ace/Throughput_Stats.h"
6 #include "ping.h"
8 int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
10 char* host = 0;
11 int nsamples = 10000;
12 int c;
14 //FUZZ: disable check_for_lack_ACE_OS
15 ACE_Get_Opt getopt (argc, argv, ACE_TEXT("h:i:"));
17 while ((c = getopt ()) != -1)
19 //FUZZ: enable check_for_lack_ACE_OS
20 switch ((char) c)
22 case 'h':
23 host = getopt.opt_arg ();
24 break;
26 case 'i':
27 nsamples = ACE_OS::atoi (getopt.opt_arg ());
28 break;
32 if (host == 0)
34 ACE_DEBUG ((LM_DEBUG, "Usage: client -h host -i iterations\n"));
35 return 1;
38 CLIENT *cl =
39 clnt_create (host, PINGPROG, PINGVERS, "tcp");
41 if (cl == 0)
43 ACE_DEBUG ((LM_DEBUG, "Cannot create client handle\n"));
44 return 1;
47 ACE_Throughput_Stats throughput;
49 ACE_hrtime_t test_start = ACE_OS::gethrtime ();
50 for (int i = 0; i != nsamples; ++i)
52 ACE_hrtime_t start = ACE_OS::gethrtime ();
54 int p = 0;
55 (void) ping_1 (&p, cl);
57 ACE_hrtime_t end = ACE_OS::gethrtime ();
59 throughput.sample (end - test_start,
60 end - start);
63 ACE_DEBUG ((LM_DEBUG, "Calibrating high resolution timer . . ."));
64 ACE_High_Res_Timer::global_scale_factor_type gsf =
65 ACE_High_Res_Timer::global_scale_factor ();
66 ACE_DEBUG ((LM_DEBUG, " done\n"));
68 throughput.dump_results ("Client", gsf);
70 return 0;