0 Replies Latest reply on Jan 29, 2006 11:07 PM by hlship

    class-wide instrument() expense?

    hlship

      How expensive is it to invoke CtClass.instrument() ?

      I'm developing some new AOP-ish things for Tapestry. The enhancements must occur to the live class at runtime, since the configuration is not known until then.

      I'm prototyping right now. For starters, most instance variables are going to be encapsulated with private instance methods that handle some additional concerns. That is, accessing instance variable _foo will change to invoking _$read_foo() or _$write_foo(). This was easy enough to code in my prototype, but started me thinking in terms of classes with perhaps a dozen or more such changes (and possibly many dozen such changes in some scenarios).

      I'm using instrument() with an ExprEditor.

      Is it more efficient to create an ExprEditor for each individual instance variable and execute instrument() multiple times? Is it more efficient to create a single, smarter ExprEditor for all instance variable changes, and invoke instrument() just once?

      The latter is slightly harder to code, so I only want to do it if it is useful, if there's an appreciable difference. Guideance?