mhonarc-users

Faster &get_last_msg_num (Was: Re: Newbie Q? - Message Jumping)

1996-11-15 06:10:50
Earl Hood said:
 [...]

If you know Perl, you might want to add some debugging output to
it to see where the problem is occuring.  The routine to check out
get_last_msg_num().  It is called if an add operation is invoked and

I had a look at get_last_msg_num().  
 - any special reason why last msg number is not stored in .mhonarc.db?
 - the routine seam to be a bit complicated, therefore ...  

I've hacked together:

sub new_get_last_msg_num {
        opendir(DIR, $'OUTDIR) || &error("ERROR: Unable to open $'OUTDIR");
        local ($max) = -1;
        grep { /msg0*(\d+).html/; $max=$1 if $1 > $max; } readdir(DIR);
        close(DIR);
        $max;
}

And got a speed up in an order of a magnitude (calling
the routines 10 times using Benchmark.pm):

o01(0) /local/mail/mhonarc-1.2.2 > perl5.00304 maxtest
New sub: (max=1531      timethis 10:  3 secs ( 2.98 usr  0.10 sys =  3.08 cpu)
Old sub: (max=1531      timethis 10: 33 secs (28.95 usr  1.12 sys = 30.07 cpu)
o01(0) /local/mail/mhonarc-1.2.2 > perl5.001 maxtest
New sub: (max=1531      timethis 10:  3 secs ( 2.58 usr  0.08 sys =  2.67 cpu)
Old sub: (max=1531      timethis 10: 32 secs (28.28 usr  0.55 sys = 28.83 cpu)

I guess I will use it here. 

Note: I have no perl 4 and therefore can't test it.

Achim
 [...]

     --ewh


<Prev in Thread] Current Thread [Next in Thread>