File: client.cpp

package info (click to toggle)
ace 6.0.3%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 49,368 kB
  • sloc: cpp: 341,826; perl: 30,850; ansic: 20,952; makefile: 10,144; sh: 4,744; python: 828; exp: 787; yacc: 511; xml: 330; lex: 158; lisp: 116; csh: 48; tcl: 5
file content (74 lines) | stat: -rw-r--r-- 1,561 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * $Id: client.cpp 84662 2009-03-02 07:38:56Z olli $
 */
#include "ace/Stats.h"
#include "ace/High_Res_Timer.h"
#include "ace/Get_Opt.h"
#include "ace/Throughput_Stats.h"

#include "ping.h"

int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
  char* host = 0;
  int nsamples = 10000;
  int c;

  //FUZZ: disable check_for_lack_ACE_OS
  ACE_Get_Opt getopt (argc, argv, ACE_TEXT("h:i:"));

  while ((c = getopt ()) != -1)
    {
  //FUZZ: enable check_for_lack_ACE_OS
      switch ((char) c)
        {
        case 'h':
          host = getopt.opt_arg ();
          break;

        case 'i':
          nsamples = ACE_OS::atoi (getopt.opt_arg ());
          break;
        }
    }

  if (host == 0)
    {
      ACE_DEBUG ((LM_DEBUG, "Usage: client -h host -i iterations\n"));
      return 1;
    }

  CLIENT *cl =
    clnt_create (host, PINGPROG, PINGVERS, "tcp");

  if (cl == 0)
    {
      ACE_DEBUG ((LM_DEBUG, "Cannot create client handle\n"));
      return 1;
    }

  ACE_Throughput_Stats throughput;

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

      int p = 0;
      (void) ping_1 (&p, cl);

      ACE_hrtime_t end = ACE_OS::gethrtime ();

      throughput.sample (end - test_start,
                         end - start);

    }

  ACE_DEBUG ((LM_DEBUG, "Calibrating high resolution timer . . ."));
  ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor ();
  ACE_DEBUG ((LM_DEBUG, " done\n"));

  throughput.dump_results ("Client", gsf);

  return 0;
}