Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Speed up hash initialization loop

by Anonymous Monk
on Jan 29, 2013 at 20:27 UTC ( #1015928=note: print w/ replies, xml ) Need Help??


in reply to Speed up hash initialization loop

How much time is spent building those hashes, and how much time is spent on disk IO?

I also see a lot of stars in your regexes (at least they're not deathstars .*). I'm sure they're not all needed. For example, in: if(/(.{1,8})\S*:\S*/){ the last \S* accomplishes nothing since it isn't captured.


Comment on Re: Speed up hash initialization loop
Select or Download Code
Re^2: Speed up hash initialization loop
by austinj (Acolyte) on Jan 30, 2013 at 14:12 UTC

    Thanks for the advice, I'm pretty sure the regex runs pretty quick - the reason being if I only run a couple profiles (20) the whole routine runs at 0.07 seconds per profile. However if I run a large number (300+) it slows down to ~1.0 seconds per profile (average). I assume this means that something with initializing/re-allocating memory to the hash is what is slowing me down, not the regex.

    Either way I took your advice and removed some unnecessary parts of the regex. But it still runs at approx the same speed.

Re^2: Speed up hash initialization loop
by austinj (Acolyte) on Jan 30, 2013 at 15:13 UTC

    I just ran one more test, I ran 100 profiles, average approx 1 second per profile. I then ran 3 profiles (that were in the 100 set) and specifically those 3 had taken 2+ seconds to run. Now with only 3 they each ran in 0.07 seconds or less. I'm not sure why it seems to already know it has a lot of profiles ... unless, I'm passing the profiles in on the command line example /home/profile_* , maybe it has to run this "ls" type command every time? it seems it should only run it once, but I'm not sure I set it up that way. I'm pulling them in like this:

    my $arg_profs  =   \@ARGV; # set the remaining arguments AFTER you have read the template

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015928]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (15)
As of 2015-07-03 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls