File: bench.pl

package info (click to toggle)
libwww-curl-simple-perl 0.100191-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 240 kB
  • sloc: perl: 685; makefile: 4
file content (54 lines) | stat: -rwxr-xr-x 1,009 bytes parent folder | download | duplicates (2)
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
53
54
#!/usr/bin/perl

use strict;
use warnings;
my $url = 'http://localhost/';

use Benchmark qw/cmpthese timethese/;
use File::Basename qw(basename);

use WWW::Curl::Easy;
use LWP::Simple qw/get/;
use WWW::Curl::Simple;

sub curl {
    # Test with WWW::Curl::Easy
    # Setting the options
    my $curl = new WWW::Curl::Easy;

    $curl->setopt(CURLOPT_HEADER,1);
    $curl->setopt(CURLOPT_URL, $url);
    my $response_body;

    # NOTE - do not use a typeglob here. A reference to a typeglob is okay though.
    open (my $fileb, ">", \$response_body);
    $curl->setopt(CURLOPT_WRITEDATA,$fileb);

    # Starts the actual request
    my $retcode = $curl->perform;
}

sub curl_simple {
    # Test with WWW::Curl::Simple
    my $curl = WWW::Curl::Simple->new();

    my $res = $curl->get($url);
    
}

sub lwp {
    # Test with LWP::Simple
    my $res = get($url);
    
}

my $results = timethese(shift || 100, {
    lwp => \&lwp,
    curl => \&curl,
    curl_simple => \&curl_simple,
});

cmpthese($results);