buunguyen / fasterflect

.NET Reflection Made Fast and Simple ⛺
https://www.nuget.org/packages/fasterflect/
Apache License 2.0
285 stars 57 forks source link

I think you should include a benchmark on .NET 4.7 #3

Open horeaper opened 6 years ago

horeaper commented 6 years ago

I have run the test under the latest .net framework 4.7 (just changed the project's target framework, not a single line of code), and the result is pretty astonishing. In short term, .net's reflection has come a long way compaired it was back in 3.5. For many tests, the buildin reflection is as fast, sometimes even faster than fasterflect's un-cached one. I ran the tests multiple times to be sure. Well done, Microsoft! There're still some cases that un-cached one is faster, but the ratio has dropped to mostly 2x. The cached one are still pretty fast, through. I think you should modify the Readme.md, tell people who want to use this project under .net 4.7 or newer, to use the cached version, or not at all.

benchmark.4.7-1.txt benchmark.4.7-2.txt benchmark.4.7-3.txt

BTW. My test machine is an i7-4700MQ, DDR3-1600 16GB, Windows 8.1 laptop.

buunguyen commented 6 years ago

Thanks for the test! I'm not surprised, reflection has gotten faster and faster every release. Eventually, I would say Fasterflect shines in 2 areas. First, if you have critical pieces of code where you want to squeeze every bit of performance out of it, then the cached API is definitely the way to go. Second, if you want an easy to use API for various types of reflection needs and don't concern too much about performance, even if built-in reflection is faster, the fluent and consistent interface might be worth it for some people.