File: bench-elasticsearch.pl

package info (click to toggle)
libhijk-perl 0.28-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 260 kB
  • sloc: perl: 1,372; makefile: 8
file content (38 lines) | stat: -rw-r--r-- 1,176 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env perl
use strict;
use warnings;
use Benchmark ':all';
use Hijk;
use HTTP::Tiny;
use LWP::UserAgent;
use HTTP::Request;

my $tiny = HTTP::Tiny->new();
my $req = HTTP::Request->new('GET','http://localhost:9200/_search');
my $body = '{"query":{"match_all":{}}}';
$req->content($body);
my $lwp = LWP::UserAgent->new();

# 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:

#           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%      --

cmpthese(10_000,{
    'tiny___' => sub {
        my $res = $tiny->get('http://localhost:9200/_search',{content => $body });
    },
    'hijk pp' => sub {
        my $res = Hijk::request({path => "/_search", body => $body,
                                 host => 'localhost',
                                 port => 9200,
                                 method => 'GET'});
    },
    'lwp____' => sub {
        my $res = $lwp->request($req);
    },
});