No, really, you guys are looking for optimization in the wrong place. How long does it take on your system for a Perl script to read a 250k text file line by line and print it line by line? Almost no time at all. I had to benchmark 100 iterations of that sort of routine just to measure a two-second execution time.
If a script, reading line by line 250k of data and outputting it via CGI, results in page loads in the order of "an eternity", there's definately a problem.
My guess is that your problem will be one of the following:
- Your flock is waiting for the file to become available. This could be awhile if there are lots of processes competing for it. The POD for flock states: Two potentially non-obvious but traditional flock semantics are that it waits indefinitely until the lock is granted, and that its locks merely advisory.
- It takes 64 seconds to load 256k of data through a 45kbps telephone modem connection.
- Long ping times, packet loss, and other network latency issues could contribute to slow page loads.
- Server load could be an issue.
But I wouldn't be too quick to blame the segment of code that reads the file line by line and prints it; that's not doing anything that would take an eternity to execute.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.