Beefy Boxes and Bandwidth Generously Provided by pair Networks
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??


in reply to Perl Objects, Internal Representation -- How??

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

  • Comment on Re: Perl Objects, Internal Representation -- How??

Replies are listed 'Best First'.
Re^2: Perl Objects, Internal Representation -- How??
by xdg (Monsignor) on Sep 15, 2006 at 17:23 UTC

    You might be interested in these OO benchmarks or in Anti-inside-out-object-ism for a comparison of some of the leading issues.

    jdhedden has worked very hard to optimize Object::InsideOut for speed, particularly in the default array-based mode. (By contrast, I've optimized Class::InsideOut for simplicity and thedamian has optimized Class::Std for complex class hierarchy management.)

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-26 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found