diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-07-11 15:38:45 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-07-11 15:38:45 +0000 |
commit | 132bf0bc9f0fab870fc51791a7cbd615cef73e3c (patch) | |
tree | 2864c59a41b6869f8f910bfdb016364f90905007 | |
parent | db80642d019a7b8abff95413e659a922a0808765 (diff) |
Add a time.log file that accumulates timing information about the
executed tests. This allows to micro benchmark relayd.
based on a diff from andre@; OK reyk@
-rw-r--r-- | regress/usr.sbin/relayd/Client.pm | 3 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/Proc.pm | 15 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-timein-http.pl | 1 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-timein.pl | 1 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-timeout-http.pl | 1 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/args-timeout.pl | 1 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/relayd.pl | 6 | ||||
-rw-r--r-- | regress/usr.sbin/relayd/remote.pl | 10 |
8 files changed, 31 insertions, 7 deletions
diff --git a/regress/usr.sbin/relayd/Client.pm b/regress/usr.sbin/relayd/Client.pm index 97a525ad645..8a8a95f3593 100644 --- a/regress/usr.sbin/relayd/Client.pm +++ b/regress/usr.sbin/relayd/Client.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Client.pm,v 1.7 2014/07/10 10:19:06 bluhm Exp $ +# $OpenBSD: Client.pm,v 1.8 2014/07/11 15:38:44 bluhm Exp $ # Copyright (c) 2010-2012 Alexander Bluhm <bluhm@openbsd.org> # @@ -31,6 +31,7 @@ sub new { my %args = @_; $args{logfile} ||= "client.log"; $args{up} ||= "Connected"; + $args{timefile} //= "time.log"; my $self = Proc::new($class, %args); $self->{connectdomain} or croak "$class connect domain not given"; diff --git a/regress/usr.sbin/relayd/Proc.pm b/regress/usr.sbin/relayd/Proc.pm index 11420053489..4fdfe439db0 100644 --- a/regress/usr.sbin/relayd/Proc.pm +++ b/regress/usr.sbin/relayd/Proc.pm @@ -1,4 +1,4 @@ -# $OpenBSD: Proc.pm,v 1.8 2014/07/10 10:19:06 bluhm Exp $ +# $OpenBSD: Proc.pm,v 1.9 2014/07/11 15:38:44 bluhm Exp $ # Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org> # @@ -20,6 +20,7 @@ use warnings; package Proc; use Carp; use Errno; +use File::Basename; use IO::File; use POSIX; use Time::HiRes qw(time alarm sleep); @@ -104,12 +105,22 @@ sub run { do { $self->child(); print STDERR $self->{up}, "\n"; + $self->{begin} = time(); $self->{func}->($self); } while ($self->{redo}); + $self->{end} = time(); print STDERR "Shutdown", "\n"; + if ($self->{timefile}) { + open(my $fh, '>>', $self->{timefile}) + or die ref($self), " open $self->{timefile} failed: $!"; + printf $fh "time='%s' duration='%.10g' ". + "forward='%s' test='%s'\n", + scalar(localtime(time())), $self->{end} - $self->{begin}, + $self->{forward}, basename($self->{testfile}); + } + IO::Handle::flush(\*STDOUT); IO::Handle::flush(\*STDERR); - POSIX::_exit(0); } diff --git a/regress/usr.sbin/relayd/args-timein-http.pl b/regress/usr.sbin/relayd/args-timein-http.pl index 6a0add6956e..e3d56a5103a 100644 --- a/regress/usr.sbin/relayd/args-timein-http.pl +++ b/regress/usr.sbin/relayd/args-timein-http.pl @@ -7,6 +7,7 @@ our %args = ( client => { func => \&http_client, len => 5, + timefile => "", }, relayd => { protocol => [ "http" ], diff --git a/regress/usr.sbin/relayd/args-timein.pl b/regress/usr.sbin/relayd/args-timein.pl index 6b3ec30a8ec..63343abe00a 100644 --- a/regress/usr.sbin/relayd/args-timein.pl +++ b/regress/usr.sbin/relayd/args-timein.pl @@ -12,6 +12,7 @@ our %args = ( write_char(@_, 4); }, sleep => 1, + timefile => "", nocheck => 1, }, relayd => { diff --git a/regress/usr.sbin/relayd/args-timeout-http.pl b/regress/usr.sbin/relayd/args-timeout-http.pl index b1899206f2c..424543011bf 100644 --- a/regress/usr.sbin/relayd/args-timeout-http.pl +++ b/regress/usr.sbin/relayd/args-timeout-http.pl @@ -7,6 +7,7 @@ our %args = ( client => { func => \&http_client, len => 5, + timefile => "", }, relayd => { protocol => [ "http" ], diff --git a/regress/usr.sbin/relayd/args-timeout.pl b/regress/usr.sbin/relayd/args-timeout.pl index f42d1a7f1ab..117a6d43404 100644 --- a/regress/usr.sbin/relayd/args-timeout.pl +++ b/regress/usr.sbin/relayd/args-timeout.pl @@ -13,6 +13,7 @@ our %args = ( }, sleep => 1, down => "Broken pipe", + timefile => "", nocheck => 1, }, relayd => { diff --git a/regress/usr.sbin/relayd/relayd.pl b/regress/usr.sbin/relayd/relayd.pl index 79d08ad2508..71c7adedabc 100644 --- a/regress/usr.sbin/relayd/relayd.pl +++ b/regress/usr.sbin/relayd/relayd.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: relayd.pl,v 1.11 2014/07/10 10:19:06 bluhm Exp $ +# $OpenBSD: relayd.pl,v 1.12 2014/07/11 15:38:44 bluhm Exp $ # Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org> # @@ -42,12 +42,14 @@ my $redo = $args{lengths} && @{$args{lengths}}; $redo = 0 if $args{client}{http_vers}; # run only one persistent connection my($sport, $rport) = find_ports(num => 2); my $s = Server->new( + forward => $ARGV[0], func => \&read_char, listendomain => AF_INET, listenaddr => "127.0.0.1", listenport => $sport, redo => $redo, %{$args{server}}, + testfile => $test, ) unless $args{server}{noserver}; my $r = Relayd->new( forward => $ARGV[0], @@ -61,11 +63,13 @@ my $r = Relayd->new( testfile => $test, ); my $c = Client->new( + forward => $ARGV[0], func => \&write_char, connectdomain => AF_INET, connectaddr => "127.0.0.1", connectport => $rport, %{$args{client}}, + testfile => $test, ) unless $args{client}{noclient}; $s->run unless $args{server}{noserver}; diff --git a/regress/usr.sbin/relayd/remote.pl b/regress/usr.sbin/relayd/remote.pl index 2e41529db46..54c462a26ed 100644 --- a/regress/usr.sbin/relayd/remote.pl +++ b/regress/usr.sbin/relayd/remote.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: remote.pl,v 1.5 2014/07/10 10:19:06 bluhm Exp $ +# $OpenBSD: remote.pl,v 1.6 2014/07/11 15:38:44 bluhm Exp $ # Copyright (c) 2010-2013 Alexander Bluhm <bluhm@openbsd.org> # @@ -99,32 +99,36 @@ if ($mode eq "relay") { my $redo = $args{lengths} && @{$args{lengths}}; $redo = 0 if $args{client}{http_vers}; # run only one persistent connection my $s = Server->new( + forward => $ARGV[0], func => \&read_char, + redo => $redo, %{$args{server}}, listendomain => AF_INET, listenaddr => ($mode eq "auto" ? $ARGV[1] : undef), listenport => ($mode eq "manual" ? $ARGV[0] : undef), - redo => $redo, + testfile => $test, ) unless $args{server}{noserver}; if ($mode eq "auto") { $r = Remote->new( forward => $ARGV[0], logfile => "relayd.log", - testfile => $test, %{$args{relayd}}, remotessh => $ARGV[3], listenaddr => $ARGV[2], connectaddr => $ARGV[1], connectport => $s ? $s->{listenport} : 1, + testfile => $test, ); $r->run->up; } my $c = Client->new( + forward => $ARGV[0], func => \&write_char, %{$args{client}}, connectdomain => AF_INET, connectaddr => ($mode eq "manual" ? $ARGV[1] : $r->{listenaddr}), connectport => ($mode eq "manual" ? $ARGV[2] : $r->{listenport}), + testfile => $test, ) unless $args{client}{noclient}; $s->run unless $args{server}{noserver}; |