File: dumbbench-thisurl.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 (52 lines) | stat: -rw-r--r-- 1,001 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env perl
use strict;
use warnings;
use Dumbbench;

use Hijk;
use HTTP::Tiny;
use LWP::UserAgent;
use HTTP::Request;

my $url = shift;

my $uri = URI->new($url);
my $tiny = HTTP::Tiny->new();
my $req = HTTP::Request->new('GET',$url);
my $lwp = LWP::UserAgent->new();

my $hijk_req_arg = {
    path => $uri->path,
    host => $uri->host,
    port => $uri->port || 80,
    method => 'GET'
};

my $bench = Dumbbench->new(
  target_rel_precision => 0.005,
  initial_runs         => 1_000,
);

$bench->add_instances(
    Dumbbench::Instance::PerlSub->new(
        name => "hijk",
        code => sub {
            my $res = Hijk::request($hijk_req_arg);
        }
    ),
    Dumbbench::Instance::PerlSub->new(
        name => "httptiny",
        code => sub {
            my $res = $tiny->get($url);
        }
    ),
    Dumbbench::Instance::PerlSub->new(
        name => "lwpua",
        code => sub {
            my $res = $lwp->request($req);
        }
    ),
);

$bench->run;
$bench->report;