Open AhmedZero opened 2 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
There's some performance degrade but not that huge. For performance test you need to use BenchmarkDotNet to get accurate result, rather than using a StopWatch around a loop iteration whose result can be affected by many other factors.
I ran it with BenchmarkDotNet and got this result:
Method | Toolchain | Mean | Error | StdDev |
---|---|---|---|---|
Example1 | .NET 6.0 | 107.742 ms | 2.0753 ms | 3.1062 ms |
Example2 | .NET 6.0 | 1.033 ms | 0.0191 ms | 0.0267 ms |
Example1 | NativeAOT | 155.764 ms | 3.4181 ms | 5.1160 ms |
Example2 | NativeAOT | 1.123 ms | 0.0222 ms | 0.0325 ms |
List itself has no performance difference between JIT and NativeAOT, while reflection in NativeAOT is a bit slower than JIT.
I don't know benchmark.net works with NativeAOT and my program has those conditions and I program it like that. when the program add a lot of elements to the list, the performance becomes bad.
List itself has no performance difference between JIT and NativeAOT, while reflection in NativeAOT is a bit slower than JIT.
Yes, this is what I am seeing as well.
NativeAOT | Method | Mean | Error | StdDev |
---|---|---|---|---|
Example1 | 175.341 ms | 11.0707 ms | 0.6068 ms | |
Example2 | 1.002 ms | 0.2061 ms | 0.0113 ms |
Without NativeAOT
Method | Mean | Error | StdDev |
---|---|---|---|
Example1 | 124.3967 ms | 2.4448 ms | 3.0919 ms |
Example2 | 0.8375 ms | 0.0163 ms | 0.0167 ms |
you're correct @hez2010
Description
when I use the following example without NativeAOT, it's very fast, but with NativeAOT, I found it's very slow.
Output
Without NativeAOT
With NativeAOT
Configuration
Win-x64 .NET 6