P is for Practical | |
PerlMonks |
Re: Perl Objects, Internal Representation -- How??by jdtoronto (Prior) |
on Sep 15, 2006 at 13:49 UTC ( [id://573135]=note: print w/replies, xml ) | Need Help?? |
Some good info in the previous post from jimt. I too have been asking some of the same questions. The big issue to deal with is that their are just SO many ways to create and manage objects in Perl. My rather limited investigation finds that blessed hashes behave somewhat like ordinary hashes - have all the same autovivification behaviour. What I did was to write a simple piece of code that watched memory usage as I instantiated the same class a number of times. As expected the memory usage is directly related to the hash size involved and has basically nothing to do with the code. Although, as pointed out before, this need not always be the case, it's up to you. Hashes with dissimilar numbers of keys seem to populate with different memory usage. When I did the same for the class re-written as an 'inside-out' (per TheDamian in Perl Best Practices) the memory usage was a little higher for each instance and the benchmark times were a little higher, but not so much as to be prohibitive. I won't publish them because I am still very much a neophyte at the OOP game and I am sure that my methodology is quite likely flawed. That being said, it is a journey that needs to be made so that I understand this stuff better. My guides have been "Object Oriented Perl" by TheDamian as well as his "Perl Best Practices". "Higher Order Perl" by Dominus has some material, as does Chapter 5 of "Perl Hacks" by TheDamian, chromatic and Ovid. There is also a lot here in the Monastery, especially in postings by AbigailII. Happy hunting, jdtoronto
In Section
Seekers of Perl Wisdom
|
|