Performance test for C # reflection

Source: Internet
Author: User
Tags comparison reflection serialization

1. Reflection serialization and dynamic compilation serialization.

Comparison results:

------Test started:Assembly:Pixysoft.Framework.Configurations.dll------

Begin createobjectusingreflection

Begin createobjectusingreflection

00:00:04.2031250

Begin createobjectusingreflection

Begin createobjectusingreflection

00:00:07.8593750

Begin createobjectusingreflection

Begin createobjectusingreflection

00:00:07.2187500

1 passed, 0 failed, 0 skipped, took 19.36 seconds (Ad hoc).

Using C # provides the fastest serialization, while reflection serialization and dynamic compilation serialization are almost the same. It is proved that the proportion of reflection acquisition data in serialization is not large.

------------------------------

2. Comparison of reflection serialization and full dynamic establishment of serialization adapters

To establish a serialization adapter is to target different objects, memory to create an object to get the data, so you do not need to get the property through reflection, but is equivalent to direct access.

------Test started:Assembly:Pixysoft.Framework.Configurations.dll------

Begin createobjectusingreflection

Begin createobjectusingreflection

00:00:04.1406250

Begin createobjectusingreflection

Begin createobjectusingreflection

00:00:08

Begin createobjectusingreflection

Begin createobjectusingreflection

00:00:07.5468750

Begin createobjectusingreflection

Begin createobjectusingreflection

00:00:01.1250000

1 passed, 0 failed, 0 skipped, took 20.91 seconds (Ad hoc).

Visible if the value is directly obtained, the fastest speed. Ascension is about 4 times times (50,000 cycles). )

----------------------

3. Compare IMessageSink and direct acquisition of data performance.

Cycle 10w, the result is:

Begin createobjectusingreflection

00:00:11.2187500

Begin createobjectusingreflection

Begin createobjectusingreflection

00:00:00.0156250

Increased by nearly 1000 times times .... fainted.

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.