Perl slowness

Perl slowness

Gabor Szabo szabgab at gmail.com
Wed Sep 9 12:23:32 IDT 2009


2009/9/9 Arie Skliarouk <skliarie at gmail.com>:
> Try to run the following on both machines:
>
> #!/usr/bin/perl
> use Time::HiRes;
> ($seconds, $microseconds) = Time::HiRes::gettimeofday;
> print "Start: $seconds.$microseconds\n";
>
> use DB;
>
> ($seconds, $microseconds) = Time::HiRes::gettimeofday;
> print "loaded DB: $seconds.$microseconds\n";
>
>
> Besides "use DB" stick couple more libraries and print the timestamp after
> each one.


That won't give you the correct results as the "use DB;"
will actually execute *before* the first call to gettimeofday

In order this to work, the first call to Time::HiRes::gettimeofday;
needs to be in a BEGIN block:



#!/usr/bin/perl
use Time::HiRes;

BEGIN {
   ($seconds, $microseconds) = Time::HiRes::gettimeofday;
   print "Start: $seconds.$microseconds\n";
}

use DB;

($seconds, $microseconds) = Time::HiRes::gettimeofday;
print "loaded DB: $seconds.$microseconds\n";



Gabor


>
> Test write speed of disks:
> time (dd if=/dev/zero of=/tmp/abc bs=1M count=500 && sync)
>
> One of the things the "use DB" does it to load several bytes of entropy from
> /dev/random. If the newer machine has much activity, the /dev/random will
> not block. Idle machine might require some time to gather entropy. Test the
> entropy as follows:
> time dd if=/dev/random of=/dev/null bs=100000 count=1

Oh, I have an Ubuntu machine where reloading Apache takes forever probably due
to some broken /dev/random issue I was never able to figure out how to fix.

Gabor




-- 
Gabor Szabo                     http://szabgab.com/blog.html
Perl Training in Israel         http://www.pti.co.il/
Test Automation Tips        http://szabgab.com/test_automation_tips.html
LinkeIn Profile:  http://www.linkedin.com/in/szabgab



More information about the Linux-il mailing list