|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Hi
I have found a nice guestbook scripts and noticed that it reads the whole guestbook data file to a variable and then adds the new enty then appends the variable contents to the file so that new entries will be at the top. I modified the script to use flock to avoid lossing and tried to change program to append only the new enty at the top using seek() put the data goes at the end of the file. so i left the program as is but I don't know if reading a larg file to memory slows down the server. |
|
#2
|
|||
|
|||
|
You'll almost certainly be getting a performance boost from flock()'ing and seek()'ing as it does take a little time to read a file into memory (and then obviously takes up a potentially large amount of space in memory). Realistically, though, unless you're getting a lot of requests and/or have a pretty sizable file (>10k) you probably won't notice much difference -- best way to tell is to run benchmarks on the code to see how it performs. The standard Benchmark.pm module suffices to do this -- check perldoc Benchmark for more information. There could also be issues with using flock() as it is not especially portable and can be slow on systems that use emulation rather than direct support of it. Your best bet really is to run the benchmarks and see what works best for you on your system.
|
|
#3
|
|||
|
|||
|
It's good for file writing/reading but it would take more RAM of the servers
Maybe the script needs a better initial design (more smaller files) ------------------ http://new.123finder.com/ - Helps you find cool domains for FREE & Registers it for only $14.95/yr http://www.guideclick.com/ - Qualified webmaster resources (affiliate programs, web design, tips) ------ Son |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Does reading larg files to memory harm? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|