Dynamic reflection Latest Version 4.0.9.22 performance report

Source: Internet
Author: User

1. Reflection call vs dynamic compilation call get and Set Value

 

Cycles: 100000

Result:

Code ------ Test started: Assembly: pixysoft. Framework. reflection. dll ------

Reflection
Time elapsed: 514 Ms
CPU time: 500 , 000 , 000ns
Gen 0 : 0
Gen 1 : 0
Gen 2 : 0

Dynamic
Time elapsed: 366 Ms
CPU time: 234 , 375 , 000ns
Gen 0 : 132
Gen 1 : 1
Gen 2 : 0

1Passed,0Failed,0Skipped, took1.11Seconds (ad hoc ).

 

Conclusion: The performance is similar, which proves that the reflection performance is not very poor.

 

2. AOP uses the attribute mode of imessagesink vs realproxy vs dynamicproxy

Loop: 10000

Result:

Code ------ Test started: Assembly: pixysoft. Framework. reflection. dll ------

AOP
Time elapsed: 961 Ms
CPU time: 953 , 125 , 000ns
Gen 0 : 71
Gen 1 : 0
Gen 2 : 0

Real
Time elapsed: 72 Ms
CPU time:78 , 125 , 000ns
Gen 0 : 8
Gen 1 : 0
Gen 2 : 0

Dynamic
Time elapsed: 59 Ms
CPU time: 62 , 500 , 000ns
Gen 0 : 8
Gen 1 : 0
Gen 2 : 0

1Passed,0Failed,0Skipped, took1.20Seconds (ad hoc ). 

It has better performance than Microsoft's realproxy.

 

3. Get the setting value through reflection vs get the setting value through dynamic compilation vs get the setting value through beanmap

Cycle 100000

Result:

Code ------ Test started: Assembly: pixysoft. Framework. reflection. dll ------

Reflect
Time elapsed: 2 , 703 Ms
CPU time: 2 , 671 , 875 , 000ns
Gen 0 : 39
Gen 1 : 0
Gen 2 : 0

Dynamic
Time elapsed: 834 Ms
CPU time: 843 , 750 , 000ns
Gen 0 : 457
Gen 1 : 0
Gen 2 : 0

Beanmap
Time elapsed: 861 Ms
CPU time: 828 , 125 , 000ns
Gen 0 : 205
Gen 1 : 0
Gen 2 : 0

1Passed,0Failed,0Skipped, took4.52Seconds (ad hoc ).

 

 

In terms of performance, beanmap is similar to dynamictype, but it is easy to handle.

 

4. Obtain type information through reflection vs dynamic compilation to obtain type information

Cycle 100000

Result:

Code ------ Test started: Assembly: pixysoft. Framework. reflection. dll ------

Reflection
Time elapsed: 268 Ms
CPU time: 250 , 000 , 000ns
Gen 0 : 72
Gen 1 : 0
Gen 2 : 0

Emit with handler Cache
Time elapsed: 229 Ms
CPU time:218 , 750 , 000ns
Gen 0 : 19
Gen 1 : 0
Gen 2 : 0

1Passed,0Failed,0Skipped, took0.59Seconds (ad hoc ). 

Again, the reflection performance is actually not bad.

 

5. realproxy implement pojo vs dynamic compilation implement pojo vs directly create pojo

Cycle 100000

Result:

Code ------ Test started: Assembly: pixysoft. Framework. reflection. dll ------

Proxy
Time elapsed: 3 , 090 Ms
CPU time: 2 , 843 , 750 , 000ns
Gen 0 : 498
Gen 1 : 0
Gen 2 : 0

Dproxy dynamic Constructor
Time elapsed: 122 Ms
CPU time: 125 , 000 , 000ns
Gen 0 : 47
Gen 1 : 1
Gen 2 : 0

Direct
Time elapsed: 4 ms
CPU time: 0ns
Gen 0 : 2
Gen 1 : 0
Gen 2 : 0

1Passed,0Failed,0Skipped, took3.41Seconds (ad hoc ).

 

 

It can be seen that the objects obtained by dynamic compilation are operated on again, and the performance is very high!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.