From: Lane S. <la...@OP...> - 2006-03-12 21:14:48
|
alex, thanks for this improvement and catch. Are there any issues or concerns you have with this proposed update? Lane --- al...@fi... wrote: From: Alex Twisleton-Wykeham-Fiennes <al...@fi...> To: web...@li... Subject: [WebMacro-user] Optimising Variable to reduce instantiation overhead Date: Sun, 12 Mar 2006 18:50:17 +0000 All, more performance tweaks, this one to the org.webmacro.engine.Variable class. performance sampling showed a large proportion of CPU time being allocated to the makeName(Object[] names) class that is invoked in the constructor to create the human-readable version of the Object[] that stores the names, which is then stored in _vname. However, _vname is only ever used in situations when you generating PropertyException Objects to provide sensible error messages, and for all "correctly functioning" instances, this is completely redundant. What I've done is:- - disabled the call to makeName(names) in the constructor - made the getVariableName() method check to see if _vname has been initialised, and if not then build the name before returning it. This is now synchronized as it changes the state of the object. - made all previous references to _vname in the Variable class invoke getVariableName() rather than accessing the variable directly. - made _vname private rather than protected thereby forcing sub-classes to access it via getVariableName() The resulting class (attached) passes all the unit tests and completely removes this overhead for all normal usage patterns. Alex |