in reply to Re: capture system output
in thread capture system output

I'm not as interested in the actual file retrieved. What I am looking to measure is the response time, so I want to see the output from wget showing when download began and completed. This is why I would prefer to parse the output within perl rather than capturing things I don't need into a file and parsing on the backend.

Replies are listed 'Best First'.
Re^3: capture system output
by Fletch (Bishop) on Jan 18, 2006 at 22:37 UTC

    Again, just use LWP (and possibly Time::HiRes if you want finer than second granularity).

    use LWP::Simple qw( get ); use Time::HiRes qw( time ); my $url = "http://..."; my $start = time; getstore( $url, "/dev/null" ); my $end = time; print "Took ", $end - $start, " seconds\n";
Re^3: capture system output
by ikegami (Patriarch) on Jan 18, 2006 at 22:48 UTC

    What's wrong with

    use LWP::Simple qw( get ); use Time::HiRes qw( time ); my $url = "http://www.perlmonks.org/"; my $start_time = time; get($url); my $end_time = time; print("The transfer took ", $end_time-$start_time, " seconds.\n");

    You could easily put that into a loop and take the average (but beware of caching proxies).

    Update: oops, I was a bit slow at posting this!

Re^3: capture system output
by brian_d_foy (Abbot) on Jan 19, 2006 at 03:28 UTC

    My weblint program, available on CPAN, has a download timer:

    $ weblint++ -t http://www.perlmonks.com 2.315 seconds

    It's probably easier to do it yourself as some of the other posts showed you, though.

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review