1#!perl -w 2#!d:\perl\bin\perl.exe 3 4# -- SOAP::Lite -- soaplite.com -- Copyright (C) 2001 Paul Kulchenko -- 5 6use strict; 7use Benchmark; 8use SOAP::Lite on_fault => sub {my($soap, $res) = @_; die ref $res ? $res->faultdetail : $soap->transport->status, "\n"}; 9use My::Examples; 10 11my %dests = ( 12 local => ['local://localhost/cgi-bin/soap.cgi' => 'http://www.soaplite.com/My/Examples'], 13 mod_perl => ['http://localhost/soap/' => 'http://www.soaplite.com/My/Examples'], 14 CGI => ['http://localhost/cgi-bin/soap.cgi' => 'http://www.soaplite.com/My/Examples'], 15 daemon => ['http://localhost:81/' => 'http://www.soaplite.com/My/Examples'], 16 'Apache::Registry' => ['http://localhost/mod_perl/soap.mod_cgi' => 'http://www.soaplite.com/My/Examples'], 17 tcpip => ['tcp://localhost:82' => 'http://www.soaplite.com/My/Examples'], 18 direct => ['' => 'My::Examples'], 19); 20 21my $s; 22 23my %tests = ( 24 simple => sub {$s->getStateName(1)}, 25 array => sub {$s->getStateName((1) x 100)}, 26 string => sub {$s->getStateName(1 x 100)}, 27); 28 29my $testnum = 3; 30my $testtime = 5; 31my %result; 32 33print STDERR <<DISCLAIMER; 34 35This test should be used only for comparison different Perl server 36implementations running in your environment. 37 38DISCLAIMER 39 40print STDERR "All tests may take up to ", keys(%dests) * keys(%tests) * $testnum * $testtime, " sec\n"; 41 42foreach my $dest (keys %dests) { 43 my($proxy, $uri) = @{$dests{$dest}}; 44 $s = $proxy ? SOAP::Lite->proxy($proxy)->uri($uri) : $uri; 45 foreach my $test (keys %tests) { 46 printf STDERR "%s [%s] ", $dest, $test; 47 eval {$tests{$test}->()}; warn('skipped, ', $@), next if $@; 48 my($tps) = 0; 49 for (1..$testnum) { 50 my $r = Benchmark::countit($testtime => $tests{$test}); 51 my($pu, $ps, $n) = @{$r}[1,2,5]; 52 $tps += $n / ($pu + $ps); 53 print STDERR "."; 54 } 55 printf STDERR " %.5s call/s\n", $result{$dest}{$test} = $tps / $testnum; 56 } 57} 58