/usr/share/cricket/util/test-url is in cricket 1.0.5-20.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 55 56 57 58 59 60 61 62 63 64 65 | #!/usr/bin/perl -w
# -*- perl -*-
# test-url: a simple script to see how fast a webserver is
#
# Copyright (C) 1998 Jeff R. Allen and WebTV Networks, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
use LWP::UserAgent;
use Time::HiRes qw(gettimeofday);
my $datalen = 0;
$ua = new LWP::UserAgent;
$ua->agent("test-url/1.0 " . $ua->agent);
$ua->timeout(30);
die("Missing URL on command line.\n") unless (defined($ARGV[0]));
$req = new HTTP::Request('GET', $ARGV[0]);
die("Could not make an HTTP request.\n") unless (defined($req));
$start = now();
my($resp) = $ua->request($req, \&callback, 4096);
$stop = now();
if (! $first) {
$first = $stop;
}
$dFirst = $first - $start;
$dTotal = $stop - $start;
$dFirst = "U" if (! $datalen);
$dTotal = "U" if (! $datalen);
print "$dTotal\n";
print "$dFirst\n";
sub callback {
my($data, $resp, $proto) = @_;
if (! defined($first)) {
$first = now();
}
$datalen += length($data);
}
sub now {
my(@t) = gettimeofday();
return $t[0] + ($t[1] / 1000000.0);
}
|