Skip to content

Commit

Permalink
examples/bench* switch to cmpthese and show some results from my arch…
Browse files Browse the repository at this point in the history
…aic laptop
  • Loading branch information
jackdoe committed Dec 6, 2013
1 parent 5e3a886 commit 74140b1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
17 changes: 7 additions & 10 deletions examples/bench-elasticsearch.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark;
use Benchmark ':all';
use Hijk;
use Hijk::HTTP::XS;
use HTTP::Tiny;
Expand All @@ -14,19 +14,16 @@
$req->content($body);
my $lwp = LWP::UserAgent->new();

# run with HACKED_REQUEST_PP=1 perl bench-elasticsearch.pl

# current results on Intel(R) Core(TM)2 Duo CPU P8400@2.26GHz with 2gb ram
# and elasticsearch with one index containing ~ 500 small documents:

#Benchmark: timing 10000 iterations of hijk pp, hijk xs, lwp____, tiny___...
# hijk pp: 4 wallclock secs ( 0.79 usr + 0.20 sys = 0.99 CPU) @ 10101.01/s (n=10000)
# hijk xs: 3 wallclock secs ( 0.48 usr + 0.30 sys = 0.78 CPU) @ 12820.51/s (n=10000)
# lwp____: 21 wallclock secs (15.06 usr + 1.91 sys = 16.97 CPU) @ 589.28/s (n=10000)
# tiny___: 11 wallclock secs ( 6.22 usr + 2.14 sys = 8.36 CPU) @ 1196.17/s (n=10000)

# Rate lwp____ tiny___ hijk pp hijk xs
#lwp____ 593/s -- -52% -94% -95%
#tiny___ 1235/s 108% -- -88% -90%
#hijk pp 10101/s 1602% 718% -- -22%
#hijk xs 12987/s 2088% 952% 29% --

timethese(10_000,{
cmpthese(10_000,{
'tiny___' => sub {
my $res = $tiny->get('http://localhost:9200/_search',{content => $body });
},
Expand Down
25 changes: 22 additions & 3 deletions examples/bench-nginx.pl
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark;
use Benchmark ':all';
use Hijk;
use Hijk::HTTP::XS;
use HTTP::Tiny;
use LWP::UserAgent;
use HTTP::Request;

foreach my $f(qw(1k.img 10k.img 100k.img 1m.img)) {

# Rate 1k.img lwp____ 1k.img tiny___ 1k.img hijk pp 1k.img hijk xs
#1k.img lwp____ 820/s -- -54% -94% -95%
#1k.img tiny___ 1776/s 117% -- -86% -90%
#1k.img hijk pp 12821/s 1464% 622% -- -29%
#1k.img hijk xs 18182/s 2118% 924% 42% --

# Rate 10k.img lwp____ 10k.img tiny___ 10k.img hijk pp 10k.img hijk xs
#10k.img lwp____ 781/s -- -54% -93% -95%
#10k.img tiny___ 1692/s 117% -- -85% -89%
#10k.img hijk pp 11364/s 1355% 572% -- -27%
#10k.img hijk xs 15625/s 1900% 823% 37% --

# Rate 100k.img lwp____ 100k.img tiny___ 100k.img hijk pp 100k.img hijk xs
#100k.img lwp____ 452/s -- -62% -93% -95%
#100k.img tiny___ 1179/s 161% -- -83% -86%
#100k.img hijk pp 6944/s 1436% 489% -- -16%
#100k.img hijk xs 8264/s 1728% 601% 19% --

foreach my $f(qw(1k.img 10k.img 100k.img)) {
my $tiny = HTTP::Tiny->new();
my $req = HTTP::Request->new('GET',"http://localhost:8080/$f");
my $lwp = LWP::UserAgent->new();
timethese(10_000,{
cmpthese(10_000,{
$f. ' tiny___' => sub {
my $res = $tiny->get("http://localhost:8080/$f");
},
Expand Down

0 comments on commit 74140b1

Please sign in to comment.