in reply to Re^4: snmpget is missing some values
in thread snmpget is missing some values
On my machine, Your test gets me 2174 echo per second, which is around 460 MICRO seconds each - yes , still not in NANO seconds.
(It helps that I am writing to an SSD disk)
I updated the code slightly to get closer to the "echo" open/close of the file, and append to it, and 10x the iterations:
This gives me:use strict; use warnings; use Benchmark 'cmpthese'; cmpthese (100000, { 'print' => sub { open my $fh, '>>', '/tmp/wp.txt' or die $!; print $fh "x\n"; close $fh; }, 'echo' => sub { system "echo x >> /tmp/we.txt"; } } ); exit;
Where the perl performance is pushing the limits of nanoseconds, at 7100 nanoseconds per write.Rate echo print echo 2168/s -- -98% print 140845/s 6397% --
In any case, the lesson learned is that perl is about 70 times faster than "echo".
This is not an optical illusion, it just looks like one.
|
|---|