Leser: 2
![]() |
![]() |
1 Eintrag, 1 Seite |
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
#!/usr/bin/perl -W
use strict;
use warnings qw(all);
use LWP::UserAgent qw(new);
use LWP::ConnCache;
use Date::Calc qw(Mktime Today Today_and_Now);
my $cache = LWP::ConnCache->new();
$| = 1;
# HTTP User Agent
my $browser = LWP::UserAgent->new;
$browser->default_headers->push_header('Accept-Encoding' => 'gzip, compressed, deflate');
$browser->timeout(15);
$browser->conn_cache($cache);
my $start = Mktime(Today_and_Now);
sub request{
my ($request, $response, $content);
# Request
$request = HTTP::Request->new(GET => 'http://board.perl-community.de');
# Request senden
$response = $browser->request($request);
# Gzipped on the fly ?
$content = $response->decoded_content;
$content = $response->content unless $content;
print ".";
}
my ($done, $round) = 0;
my $duration = 10;
while(!$done){
request();
$done = 1 if ((Mktime(Today_and_Now))-$start == $duration);
$round++;
}
$cache->drop();
print "\n$round requests in $duration seconds\n";
![]() |
![]() |
1 Eintrag, 1 Seite |