Next | Making Programs Faster | 18 |
# usage: webgrep PATTERN urls... use LWP::Simple 'get'; my $pat = shift; my @contexts; for my $url (@ARGV) { my $doc = get($url); unless (defined $doc) { warn "Couldn't fetch $doc; skipping\n"; next; }
while ($doc =~ m/$pat/oig) { push @contexts, substr($doc, pos($doc) - 30, 60); } } print join("\n--------\n", @contexts), "\n";
This program's wallclock time is dominated by the call to get
get spends most of its time waiting for messages to travel across the network
We say that the program is I/O bound
Next | Copyright © 2003 M. J. Dominus |