Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Micro optimisations can pay off, and needn't be a maintenance problem

by dws (Chancellor)
on Nov 13, 2002 at 10:29 UTC ( [id://212545]=note: print w/replies, xml ) Need Help??


in reply to Re: Micro optimisations can pay off, and needn't be a maintenance problem
in thread Micro optimisations can pay off, and needn't be a maintenance problem

You optimize one thing, attribute access, by 25%, but you get an overall speed up of a factor of 6. How's that possible?

The benchmark test cases include overhead for object creation. That might skew the test results a bit.

Getters and setters aren't benchmarked individually. Instead, the benchmark tests call getters and setters an equal number of times. But in the Z Buffer Demo getters seem to predominate (based on a quick read the code). Intuitively, getters are going to be faster than setters, perhaps enough so to explain a factor of 6 improvement.

  • Comment on Re: Re: Micro optimisations can pay off, and needn't be a maintenance problem

Replies are listed 'Best First'.
Re: Re: Re: Micro optimisations can pay off, and needn't be a maintenance problem
by pilgrim (Monk) on Nov 14, 2002 at 23:28 UTC
    Well, my analysis in this case should be taken with a salt lick, but breaking it out into the original (overall) benchmark followed by one each create/set and create/get shows that the "get" case is roughly 33% (up to 40%) faster than the "set" case. It also shows that the "set" gets (2%-3%) more of an improvement out of this optimization than the "get" does.

    Breaking it out further, and accessing the previously-set $thing1 through $thing4 rather than creating a new object each iteration, I see that the individual "get" and "set" are actually about 37% faster.

    So object creation does factor in, and getters are faster. It's still "only" a 37% improvement, rather than sixfold, but it's not a unilateral 37%.

Log In?
Username:
Password:

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

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

    No recent polls found