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 */
12 #if defined (ACE_HAS_THREADS)
16 t_flags_ (THR_DETACHED
),
17 high_water_mark_ (8 * 1024),
18 low_water_mark_ (1024),
20 initial_queue_length_ (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"))
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)
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"
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
,
67 (int) rusage
.pr_inblk
,
68 (int) rusage
.pr_oublk
,
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,
78 (int) rusage
.pr_ioch
);
80 #endif /* ACE_HAS_PRUSAGE_T */
82 ACE_OS::printf ("---------------------\n"
85 "system time = %.3f\n"
86 "---------------------\n",
87 et
.real_time
, et
.user_time
, et
.system_time
);
90 // Manages the options.
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"));
102 while ((c
= getopt ()) != -1)
103 //FUZZ: enable check_for_lack_ACE_OS
107 this->t_flags (THR_BOUND
);
110 this->consumer_file (getopt
.opt_arg ());
113 this->consumer_port (getopt
.opt_arg ());
116 this->debugging_
= 1;
119 this->high_water_mark (ACE_OS::atoi (getopt
.opt_arg ()));
122 this->iterations (ACE_OS::atoi (getopt
.opt_arg ()));
125 this->low_water_mark (ACE_OS::atoi (getopt
.opt_arg ()));
128 this->initial_queue_length (ACE_OS::atoi (getopt
.opt_arg ()));
131 this->message_size (ACE_OS::atoi (getopt
.opt_arg ()));
134 this->t_flags (THR_NEW_LWP
);
137 this->supplier_file (getopt
.opt_arg ());
140 this->supplier_port (getopt
.opt_arg ());
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 */
151 this->thr_count (ACE_OS::atoi (getopt
.opt_arg ()));
154 this->verbosity_
= 1;
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]));
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"
187 "%8d = THR_NEW_LWP\n",
188 ACE_OS::thr_getconcurrency (),
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 */