Syntactic Confectionery Delight | |
PerlMonks |
Re: Comparing memory requirements for hashes and arraysby toma (Vicar) |
on Sep 04, 2001 at 09:30 UTC ( [id://109983]=note: print w/replies, xml ) | Need Help?? |
Many times a database table fits nicely in a list of
lists (2 dimensional array). Other times a hash works
better. I worked on a project where list of lists was
chosen after extensive testing. Questions to think about for hash versus array:
Is your data rectangular?
What sort of iteration will you need to do?
Are the keys of the hash simple to implement?
Do you need to keep reloading your data structures from
the database, or are they static? You can presize arrays so that they have less memory overhead. For measuring memory consumption, the normal tools such as ps and top will work reasonably well. To see if high-level behavior such as copy-on-write is working properly, you need to stress test your server to see how much traffic load causes it to swap. You really need to use a development server for this type of testing. Writing a stress-test program is fun! Create a program using LWP to simulate the behavior of a single user. Run a bunch of these programs at the same time to simulate the load caused by many users. You can get typical user behavior patterns by examining your server log files. This approach allows you make impressive claims, such as "This system is scaled for two second page load times with 1000 simultaneous users." It should work perfectly the first time! - toma
In Section
Seekers of Perl Wisdom
|
|