Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Performance Trap - Opening/Closing Files Inside a Loop

by TedPride (Priest)
on Dec 10, 2004 at 10:03 UTC ( #413793=note: print w/replies, xml ) Need Help??

in reply to Performance Trap - Opening/Closing Files Inside a Loop

tachyon is correct that printing once to each file is much more efficient then printing hundreds of thousands of times. The question is, do you have enough memory to do this? I'd personally store output in a hash, with a filehandle and output buffer for each file, and just print to the filehandle whenever the buffer reached allowable memory / number of files amount of data. Anything still in the buffers at the end of the run would also be printed to the files.

Allowing 10 MB of memory and 100 files, for instance, you could print whenever the buffer for an individual file reached 100K or so.

  • Comment on Re: Performance Trap - Opening/Closing Files Inside a Loop

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://413793]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2018-02-22 09:53 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (289 votes). Check out past polls.