Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / examples / ASX / UPIPE_Event_Server / Options.cpp
bloba12e7ffb415f667207923603c8702f4b9db78b07
1 #include "ace/Get_Opt.h"
2 #include "ace/Log_Msg.h"
3 #include "ace/OS_NS_Thread.h"
4 #include "ace/OS_NS_stdio.h"
5 #if defined (ACE_HAS_TRACE)
6 # include "ace/OS_NS_strings.h"
7 #endif /* ACE_HAS_TRACE */
9 #include "Options.h"
12 #if defined (ACE_HAS_THREADS)
14 Options::Options ()
15 : thr_count_ (4),
16 t_flags_ (THR_DETACHED),
17 high_water_mark_ (8 * 1024),
18 low_water_mark_ (1024),
19 message_size_ (128),
20 initial_queue_length_ (0),
21 iterations_ (100000),
22 debugging_ (0),
23 verbosity_ (0),
24 consumer_port_ (ACE_TEXT ("-p 10000")),
25 supplier_port_ (ACE_TEXT ("-p 10001")),
26 consumer_file_ (ACE_TEXT ("-f/tmp/conupipe")),
27 supplier_file_ (ACE_TEXT ("-f/tmp/supupipe"))
31 Options::~Options ()
35 void Options::print_results ()
37 ACE_Profile_Timer::ACE_Elapsed_Time et;
38 this->itimer_.elapsed_time (et);
40 #if defined (ACE_HAS_PRUSAGE_T)
41 prusage_t rusage;
42 this->itimer_.get_rusage (rusage);
44 if (options.verbose ())
46 ACE_OS::printf ("final concurrency hint = %d\n", ACE_OS::thr_getconcurrency ());
47 ACE_OS::printf ("%8d = lwpid\n"
48 "%8d = lwp count\n"
49 "%8d = minor page faults\n"
50 "%8d = major page faults\n"
51 "%8d = input blocks\n"
52 "%8d = output blocks\n"
53 "%8d = messages sent\n"
54 "%8d = messages received\n"
55 "%8d = signals received\n"
56 "%8ds, %dms = wait-cpu (latency) time\n"
57 "%8ds, %dms = user lock wait sleep time\n"
58 "%8ds, %dms = all other sleep time\n"
59 "%8d = voluntary context switches\n"
60 "%8d = involuntary context switches\n"
61 "%8d = system calls\n"
62 "%8d = chars read/written\n",
63 (int) rusage.pr_lwpid,
64 (int) rusage.pr_count,
65 (int) rusage.pr_minf,
66 (int) rusage.pr_majf,
67 (int) rusage.pr_inblk,
68 (int) rusage.pr_oublk,
69 (int) rusage.pr_msnd,
70 (int) rusage.pr_mrcv,
71 (int) rusage.pr_sigs,
72 (int) rusage.pr_wtime.tv_sec, (int) rusage.pr_wtime.tv_nsec / 1000000,
73 (int) rusage.pr_ltime.tv_sec, (int) rusage.pr_ltime.tv_nsec / 1000000,
74 (int) rusage.pr_slptime.tv_sec, (int) rusage.pr_slptime.tv_nsec / 1000000,
75 (int) rusage.pr_vctx,
76 (int) rusage.pr_ictx,
77 (int) rusage.pr_sysc,
78 (int) rusage.pr_ioch);
80 #endif /* ACE_HAS_PRUSAGE_T */
82 ACE_OS::printf ("---------------------\n"
83 "real time = %.3f\n"
84 "user time = %.3f\n"
85 "system time = %.3f\n"
86 "---------------------\n",
87 et.real_time, et.user_time, et.system_time);
90 // Manages the options.
91 Options options;
93 void
94 Options::parse_args (int argc, ACE_TCHAR *argv[])
96 ACE_LOG_MSG->open (argv[0]);
98 //FUZZ: disable check_for_lack_ACE_OS
99 ACE_Get_Opt getopt (argc, argv, ACE_TEXT ("C:c:bdH:i:L:l:M:nS:s:t:T:v"));
100 int c;
102 while ((c = getopt ()) != -1)
103 //FUZZ: enable check_for_lack_ACE_OS
104 switch (c)
106 case 'b':
107 this->t_flags (THR_BOUND);
108 break;
109 case 'C':
110 this->consumer_file (getopt.opt_arg ());
111 break;
112 case 'c':
113 this->consumer_port (getopt.opt_arg ());
114 break;
115 case 'd':
116 this->debugging_ = 1;
117 break;
118 case 'H':
119 this->high_water_mark (ACE_OS::atoi (getopt.opt_arg ()));
120 break;
121 case 'i':
122 this->iterations (ACE_OS::atoi (getopt.opt_arg ()));
123 break;
124 case 'L':
125 this->low_water_mark (ACE_OS::atoi (getopt.opt_arg ()));
126 break;
127 case 'l':
128 this->initial_queue_length (ACE_OS::atoi (getopt.opt_arg ()));
129 break;
130 case 'M':
131 this->message_size (ACE_OS::atoi (getopt.opt_arg ()));
132 break;
133 case 'n':
134 this->t_flags (THR_NEW_LWP);
135 break;
136 case 'S':
137 this->supplier_file (getopt.opt_arg ());
138 break;
139 case 's':
140 this->supplier_port (getopt.opt_arg ());
141 break;
142 case 'T':
143 #if defined (ACE_HAS_TRACE)
144 if (ACE_OS::strcasecmp (getopt.opt_arg (), ACE_TEXT ("ON")) == 0)
145 ACE_Trace::start_tracing ();
146 else if (ACE_OS::strcasecmp (getopt.opt_arg (), ACE_TEXT ("OFF")) == 0)
147 ACE_Trace::stop_tracing ();
148 #endif /* ACE_HAS_TRACE */
149 break;
150 case 't':
151 this->thr_count (ACE_OS::atoi (getopt.opt_arg ()));
152 break;
153 case 'v':
154 this->verbosity_ = 1;
155 break;
156 default:
157 ACE_OS::fprintf (stderr, "%s\n"
158 "\t[-b] (THR_BOUND)\n"
159 "\t[-C consumer file]\n"
160 "\t[-c consumer port]\n"
161 "\t[-d] (enable debugging)\n"
162 "\t[-H high water mark]\n"
163 "\t[-i number of test iterations]\n"
164 "\t[-L low water mark]\n"
165 "\t[-M] message size\n"
166 "\t[-n] (THR_NEW_LWP)\n"
167 "\t[-q max queue size]\n"
168 "\t[-S supplier file]\n"
169 "\t[-s supplier port]\n"
170 "\t[-t number of threads]\n"
171 "\t[-v] (verbose)\n",
172 ACE_TEXT_ALWAYS_CHAR (argv[0]));
173 ACE_OS::exit (1);
174 /* NOTREACHED */
175 break;
178 if (this->verbose ())
179 ACE_OS::printf ("%8d = initial concurrency hint\n"
180 ACE_SIZE_T_FORMAT_SPECIFIER_ASCII " = total iterations\n"
181 ACE_SIZE_T_FORMAT_SPECIFIER_ASCII " = thread count\n"
182 ACE_SIZE_T_FORMAT_SPECIFIER_ASCII " = low water mark\n"
183 ACE_SIZE_T_FORMAT_SPECIFIER_ASCII " = high water mark\n"
184 ACE_SIZE_T_FORMAT_SPECIFIER_ASCII " = message_size\n"
185 ACE_SIZE_T_FORMAT_SPECIFIER_ASCII " = initial queue length\n"
186 "%8d = THR_BOUND\n"
187 "%8d = THR_NEW_LWP\n",
188 ACE_OS::thr_getconcurrency (),
189 this->iterations (),
190 this->thr_count (),
191 this->low_water_mark (),
192 this->high_water_mark (),
193 this->message_size (),
194 this->initial_queue_length (),
195 (this->t_flags () & THR_BOUND) != 0,
196 (this->t_flags () & THR_NEW_LWP) != 0);
199 #endif /* ACE_HAS_THREADS */