From 888e70d7cef8362d2593c3f8ba1db2a6970c7e99 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 28 Sep 2010 10:58:15 -0500 Subject: [PATCH] made benchmark tool --- bin/util/benchmark.pl | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 bin/util/benchmark.pl diff --git a/bin/util/benchmark.pl b/bin/util/benchmark.pl new file mode 100644 index 00000000..374c616d --- /dev/null +++ b/bin/util/benchmark.pl @@ -0,0 +1,50 @@ +use strict; +use LWP::UserAgent; +use JSON qw(to_json from_json); +use 5.010; +use Getopt::Long; +use Time::HiRes; + +my $empire_name; +my $password; +my $server; +GetOptions( + 'empire-name=s' => \$empire_name, + 'password=s' => \$password, + 'server=s' => \$server, +); + +unless ($empire_name && $password && $server) { + say "Usage: $0 --empire-name=xxx --password=xxx --server=us1.lacunaexpanse.com"; + exit; +} + +my $t = [Time::HiRes::gettimeofday]; +my $ua = LWP::UserAgent->new; +$ua->timeout(30); +my $content = { + jsonrpc => '2.0', + id => 1, + method => 'benchmark', + params => [$empire_name, $password, 'benchmark'], +}; +#say "REQUEST: ".to_json($content); +my $response = $ua->post('https://'.$server.'/empire', + Content_Type => 'application/json', + Content => to_json($content), + Accept => 'application/json', + ); +#say "RESPONSE: ".$response->content; +my $result = from_json($response->content); +my $total_time = Time::HiRes::tv_interval($t); + +my $internal_time; +foreach my $key (keys %{$result->{result}}) { + say $key.' = '.$result->{result}{$key}; + $internal_time += $result->{result}{$key}; +} +say "Internal Time = ".$internal_time; +say "External Time = ".($total_time - $internal_time); +say "Total Time = ".$total_time; + + -- 2.51.2