Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / performance-tests / SCTP / run_spectrum.pl
blobf4a7cc9d8a18138a091645faee73757fe849ead9
1 eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
2 & eval 'exec perl -S $0 $argv:q'
3 if 0;
6 use warnings;
7 use strict;
9 use lib "$ENV{ACE_ROOT}/bin";
10 use PerlACE::Run_Test;
11 use Getopt::Long;
12 use Pod::Usage;
14 #### Program Documentation ####
16 =head1 NAME
18 run_spectrum.pl - Run a spectrum of performance tests.
20 =head1 SYNOPSIS
22 run_spectrum.pl [ --help ]
23 [ --manual ]
24 [ --service (STREAM|SEQPACK) ]
25 [ --protocol (TCP|SCTP) ]
26 [ --config_file filename ]
28 =head1 OPTIONS
30 =over 8
32 =item B<--help, -h>
34 Print this help message and exit.
36 =item B<--manual, -m>
38 Print full documentation and exit.
40 =item B<--service, -s> (STREAM|SEQPACK)
42 Select SOCK_STREAM or SOCK_SEQPACK service respectively. The default
43 is SOCK_STREAM.
45 =item B<--protocol, -p> (TCP|SCTP)
47 Select TCP or SCTP transport protocol. The default is TCP. Note that
48 TCP cannot be used together with the SEQPACK service.
50 =item B<--config_file, -c> filename
52 Read configuration parameters from the nominated file. By default,
53 parameters are read from C<run_spectrum.config> in the current
54 directory.
56 =back
58 =head1 DESCRIPTION
60 This directory contains performance tests for measuring round-trip
61 latency statistics of ACE synchronous messaging using unmarshalled
62 ACE_CDR::Octet.
64 The SOCK_STREAM performance test comprises SOCK_STREAM_clt on the
65 client side and SOCK_STREAM_srv on the server side. The SOCK_SEQPACK
66 performance test comprises SOCK_SEQPACK_clt on the client side and
67 SOCK_SEQPACK_srv on the server side.
69 People who are interested in round-trip latency often want to see a
70 I<spectrum> of statistics for a range of payload sizes. The job of
71 this script, B<run_spectrum.pl>, is to run the client-side
72 performance-test program repeatedly, so as to generate a spectrum of
73 statistics.
75 The script supports two types of services (SOCK_STREAM and
76 SOCK_SEQPACK) and two protocols (TCP and UDP). All combinations are
77 valid except TCP over SOCK_SEQPACK. Please see L<"OPTIONS"> for
78 information about the command-line options that specify the service
79 and the protocol.
81 By default, B<run_spectrum.pl> will execute SOCK_STREAM_clt (or
82 SOCK_SEQPACK_clt) with a minimal set of command-line options. You can
83 specify additional options in an external configuration file. By
84 default, the configuration file is called C<run_spectrum.config>. You
85 may name an alternate configuration file using the B<--config_file>
86 option.
88 The configuration file should contain the options that you would
89 ordinarly give to SOCK_STREAM_clt or SOCK_SEQPACK_clt on the command
90 line. To see the command-line options available for these programs,
91 please run C<SOCK_STREAM_clt --help> or C<SOCK_SEQPACK_clt --help>.
92 Note that the options B<-s> and B<-t> are used by this script when it
93 launches the client. An occurrence of either of these options in the
94 configuration file will be ignored as redundant.
96 The client is executed 15 times: once for each payload size from 2^2
97 bytes to 2^16 bytes. (SCTP tests only go up to 2^15 bytes because of
98 limitations in our SCTP implementation.) Histograms summarizing the
99 round-trip latency performance are dumped to a file called
100 C<TIMESTAMP.spectrum> where C<TIMESTAMP> is the current time in
101 hyphen-delimited form.
103 =head1 EXAMPLES
105 B<Example 1>: Run a spectrum of TCP performance tests using
106 SOCK_STREAM with both endpoints on the local machine. Each test in
107 the spectrum should have 10,000 data points.
109 =over 4
111 =item 1.
113 Start the SOCK_STREAM server on the local machine with the S<C<-t
114 tcp>> option:
116 % ./SOCK_STREAM_srv -t tcp
118 =item 2.
120 Configure the client to run 10,000 individual trials:
122 % echo '"-c 10000"' > run_spectrum.config
124 =item 3.
126 Execute B<run_spectrum.pl>:
128 % ./run_spectrum.pl
130 (The script uses TCP and SOCK_STREAM by default.)
132 =back
134 B<Example 2>: Run a spectrum of SCTP performance tests using
135 SOCK_SEQPACK with one endpoint on the local machine and one endpoint
136 on a remote machine that happens to be named oneida. Each test in the
137 spectrum should have 50,000 data points.
139 =over 4
141 =item 1.
143 On the remote host oneida, start the SOCK_SEQPACK server:
145 % ./SOCK_SEQPACK_srv
147 =item 2.
149 On the local host, configure the client to run 50,000 individual
150 trials and to look for the server on oneida:
152 % echo '"-c 50000 -H oneida"' > run_spectrum.config
154 =item 3.
156 On the local host, execute B<run_spectrum.pl>:
158 % ./run_spectrum.pl --service SEQPACK --protocol SCTP
160 =back
162 =cut
164 # Global variable declarations
165 my $help = 0;
166 my $manual = 0;
167 my $service = "stream";
168 my $protocol = "tcp";
169 my $config_file = "run_spectrum.config";
170 my $options = "";
171 my $output_file;
173 # Map from services to client programs
174 my %client_programs = (stream => "SOCK_STREAM_clt",
175 seqpack => "SOCK_SEQPACK_clt");
177 #### MAIN PROGRAM ####
179 # Canonicalize arguments to lower-case
180 tr/A-Z/a-z/ for @ARGV;
182 # Use Getopt::Long to parse options
183 GetOptions ("help" => \$help,
184 "manual" => \$manual,
185 "service=s" => \$service,
186 "protocol=s" => \$protocol,
187 "config_file=s" => \$config_file
190 # Show help if requested
191 pod2usage(1) if $help;
193 # Show manual if requested
194 pod2usage(-verbose => 2) if $manual;
196 # Validate service option
197 $service =~ s/seqpacket/seqpack/; # Accept "seqpacket" as synonym for "seqpack"
198 $service =~ /^(stream|seqpack)$/
199 or pod2usage("Service must be STREAM or SEQPACK\n");
201 $protocol =~ /^(tcp|sctp)$/
202 or pod2usage("Protocol must be TCP or SCTP\n");
204 $service eq "seqpack" and $protocol eq "tcp"
205 and pod2usage("Cannot use SEQPACK service with TCP\n");
207 # Open config file
208 open CONFIG, "< $config_file"
209 or die "cannot open file: $config_file\n";
211 # Read options from the config file. The options are defined as the
212 # first double-quoted string that is not to the right of a pound sign.
213 # (Pound signs and quotes cannot be escaped.)
215 while (<CONFIG>) {
216 chomp;
217 if (/^[^\#]*?\"(.*?)\"/) {
218 $options = $1;
219 last;
223 # Close config file
224 close CONFIG;
226 # Print options
227 print "Read options from $config_file: \"$options\"\n\n";
229 # Name a unique file to store the results in.
230 ($output_file = localtime() . ".spectrum") =~ tr/ /-/;
232 # Run the test for message sizes ranging from 2^2 bytes to 2^16 bytes
233 # (SCTP tests only go up to 2^15 bytes because of limitations in our
234 # SCTP implementation)
235 my $max_size = 16;
236 $max_size = 15 if $protocol eq "sctp";
237 for (my $i = 2; $i <= $max_size; ++$i) {
239 # Assemble client parameters and print out the command line
240 my $client_params = "-t $protocol -s $i $options >> $output_file";
241 print "$client_programs{$service} $client_params\n";
243 # Configure client
244 my $client =
245 new PerlACE::Process($client_programs{$service}, $client_params);
247 # Spawn client
248 $client->Spawn();
250 # Wait for client to finish
251 $client->Wait();
253 # Remind the client that it's finished running
254 $client->{RUNNING} = 0;
256 # Sleep for a while
257 sleep 5;