dev@glassfish.java.net

Re: Performance tip of the day: config bean attribute access

From: Byron Nevins <byron.nevins_at_oracle.com>
Date: Fri, 12 Apr 2013 10:59:27 -0700

+1

I've seen code where the same exact method is called four times. Once
you've stepped through every bit of code that gets called with proxies
-- you never make that mistake again!



On 4/10/13 2:53 PM, Tom Mueller wrote:
> As I'm studying the GF code looking for performance improvements, I've
> come across a common pattern that, if avoided broadly, could have a
> positive impact on performance. The pattern is this:
>
> Given some config bean, "bean" with a sub element called "some-value",
> we have code that does:
>
> if (bean.getSomeValue() != null) {
> ValueType v = bean.getSomeValue();
> // do something with v
> }
>
> Here, the assumption is that bean.getSomeValue() is cheap to call. But
> given the reflection and transactions and numerous layers in the
> config bean framework, this is not true. This can be more efficiently
> written as:
>
> ValueType v = bean.getSomeValue();
> if (v != null) {
> // do something with v
> }
>
> Thanks.
> Tom
>
>
>

-- 
---
All Generalizations are false.  Including this one.