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

Re: File slurping efficiency

by KM (Priest)
on Aug 11, 2000 at 22:20 UTC ( [id://27565]=note: print w/replies, xml ) Need Help??


in reply to File slurping efficiency

I just did a quick test of opening a small file 500 times using method A, then grepping, and method B and using a match. Results of my benchmark:

Method A:
1 wallclock secs ( 0.16 usr + 0.02 sys = 0.18 CPU)

Method B:
0 wallclock secs ( 0.04 usr + 0.03 sys = 0.07 CPU)

Results may vary, try it yourself to see what you get. Not very surprising since Method A will need to populate an array, the loop through it and match. Method B just does the match.

UPDATE: Out of curiosity I did Method A withought building an array and simply grepping from the open filehandle. Small difference:
0 wallclock secs ( 0.12 usr + 0.03 sys = 0.15 CPU)

Cheers,
KM

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-03-29 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found