You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Robert <ro...@bull-enterprises.com> on 2003/10/05 07:01:03 UTC
Re: [BeanUtils] Interesting Microbenchmarks
That was the only change? Adding in the BeanMap calls? I like that!
I'll look more into CGlib, thanks.
Robert
Chris Nokleberg wrote:
> Robert wrote:
>
>
>>What exactly did CGLIB do in this case? I took a look at the web site,
>>but from what I could see, CGLIB is a way to wrap classes for method
>>interception ala proxy style. I'm sure I'm missing something, but I
>>couldn't quite tell from the docs.
>
>
> The docs need some work. The original purpose for CGLIB was as better
> version of java.lang.reflect.Proxy, but it has grown into a repository for
> "all things code generated". The benchmarks I generated used the BeanMap
> class (net.sf.cglib.beans.BeanMap in CVS), which is a dynamic Map view of a
> bean. To copy one bean to another I just did
>
> BeanMap.create(bean2).putAll(BeanMap.create(bean1));
>
> I intend to eventually add a dedicated BeanCopier class which will eliminate
> the remaining overhead.
>
> Chris
>
>
>>Chris Nokleberg wrote:
>>
>>>I modified the PropertyUtils benchmark to use CGLIB:
>>>
>>>Method Dest Orig CGLIB? Duration
>>>-------------- ---- ---- ------ --------
>>>
>>>copyProperties bean bean no 4,871
>>>copyProperties bean bean yes 560
>>>copyProperties bean map no 2,895
>>>copyProperties bean map yes 461
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [BeanUtils] Interesting Microbenchmarks
Posted by Chris Nokleberg <ch...@sixlegs.com>.
Robert wrote:
> I'll have to check that one out too. Any particular reason why you chose
> ASM over BCEL?
Yes... :-)
- less than 1/10th the size
- generates classes faster (less memory consumption, etc.)
- simpler API
- thread-safe (BCEL had/has some bugs)
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [BeanUtils] Interesting Microbenchmarks
Posted by Robert <ro...@bull-enterprises.com>.
Maybe the ASM main page says it all :-)
Robert wrote:
> I'll have to check that one out too. Any particular reason why you chose
> ASM over BCEL?
>
> Chris Nokleberg wrote:
>
>> Robert wrote:
>>
>>> By 'generated', do you mean a runtime class generated (something like
>>> BCEL for example), not source generation which is then compiled?
>>>
>>> The numbers are impressive regardless.
>>
>>
>>
>> Yes, everything in CGLIB uses the ASM bytecode manipulation library
>> (http://asm.objectweb.org/) to dynamically generate classes at runtime.
>>
>> Chris
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [BeanUtils] Interesting Microbenchmarks
Posted by Robert <ro...@bull-enterprises.com>.
I'll have to check that one out too. Any particular reason why you chose
ASM over BCEL?
Chris Nokleberg wrote:
> Robert wrote:
>
>>By 'generated', do you mean a runtime class generated (something like
>>BCEL for example), not source generation which is then compiled?
>>
>>The numbers are impressive regardless.
>
>
> Yes, everything in CGLIB uses the ASM bytecode manipulation library
> (http://asm.objectweb.org/) to dynamically generate classes at runtime.
>
> Chris
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [BeanUtils] Interesting Microbenchmarks
Posted by Chris Nokleberg <ch...@sixlegs.com>.
Robert wrote:
> By 'generated', do you mean a runtime class generated (something like
> BCEL for example), not source generation which is then compiled?
>
> The numbers are impressive regardless.
Yes, everything in CGLIB uses the ASM bytecode manipulation library
(http://asm.objectweb.org/) to dynamically generate classes at runtime.
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [BeanUtils] Interesting Microbenchmarks
Posted by Robert <ro...@bull-enterprises.com>.
By 'generated', do you mean a runtime class generated (something like
BCEL for example), not source generation which is then compiled?
The numbers are impressive regardless.
Robert
Chris Nokleberg wrote:
> I finally got around to adding a dedicated BeanCopier class to CGLIB.
> The API looks something like:
>
> BeanCopier copier = BeanCopier.create(bean1.getClass(), bean2.getClass());
> copier.copy(bean1, bean2);
>
> The copiers are cached, but if you can reuse the very same instance you get
> much faster times, so I've benchmarked both ways. This is for 100000
> iterations on JDK 1.4.2_01 (Linux).
>
> CGLIB? Reuse copier? Duration
> ------ ------------- --------
> No N/A 4,110 ms <-- PU.copyProperties(bean,bean)
> Yes No 87 ms
> Yes Yes 5 ms
>
> The results were better than I expected :-) The generated code is very
> simple which I think lets HotSpot really go to town.
>
> Chris
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [BeanUtils] Interesting Microbenchmarks
Posted by Vic Cekvenich <ce...@baseBeans.com>.
This would be great, and here's the good news:
http://www.objectweb.org/wws/arc/architecture/2003-10/msg00048.html
Chris Nokleberg wrote:
> I finally got around to adding a dedicated BeanCopier class to CGLIB.
> The API looks something like:
>
> BeanCopier copier = BeanCopier.create(bean1.getClass(), bean2.getClass());
> copier.copy(bean1, bean2);
>
> The copiers are cached, but if you can reuse the very same instance you get
> much faster times, so I've benchmarked both ways. This is for 100000
> iterations on JDK 1.4.2_01 (Linux).
>
> CGLIB? Reuse copier? Duration
> ------ ------------- --------
> No N/A 4,110 ms <-- PU.copyProperties(bean,bean)
> Yes No 87 ms
> Yes Yes 5 ms
>
> The results were better than I expected :-) The generated code is very
> simple which I think lets HotSpot really go to town.
>
> Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [BeanUtils] Interesting Microbenchmarks
Posted by Chris Nokleberg <ch...@sixlegs.com>.
I finally got around to adding a dedicated BeanCopier class to CGLIB.
The API looks something like:
BeanCopier copier = BeanCopier.create(bean1.getClass(), bean2.getClass());
copier.copy(bean1, bean2);
The copiers are cached, but if you can reuse the very same instance you get
much faster times, so I've benchmarked both ways. This is for 100000
iterations on JDK 1.4.2_01 (Linux).
CGLIB? Reuse copier? Duration
------ ------------- --------
No N/A 4,110 ms <-- PU.copyProperties(bean,bean)
Yes No 87 ms
Yes Yes 5 ms
The results were better than I expected :-) The generated code is very
simple which I think lets HotSpot really go to town.
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org