Elwarren, I implemeneted your code and then I looked at it and realized that I could get
the same functionality at half the speed.
UPDATE: errr...I should say at twice the speed...oops, typing faster than my brain
I thought you might be interested.
Here is the code:
#!/usr/bin/perl
@pinglist=('10.17.1.60', '10.17.1.61', '10.17.1.62', '10.17.1.63');
use Net::Ping;
my $p = Net::Ping->new(icmp, 5);
foreach $h (@pinglist) {
if ($p->ping($h, 5)) { print "[p (ok) $h]"; } else { print "[p <NO
+> $h]"; }
print "\n";
}
$p->close;
And the benchmarking results:
H:\>benchingping.pl
Benchmark: timing 5000 iterations of inline, modular...
inline: 63 wallclock secs (22.26 usr + 8.72 sys = 30.98 CPU) @ 16
+1.37/s (n=
5000)
modular: 104 wallclock secs (38.02 usr + 23.94 sys = 61.95 CPU) @ 8
+0.71/s (n=
5000)
Cool, huh? Thanks again!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.