且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我可以检查 C# 编译器是否内联了方法调用吗?

更新时间:2022-12-13 17:16:58

不,你不能.更重要的是,决定内联的不是将代码转换为 IL 的 VS 编译器,而是将 IL 转换为机器码的 JIT 编译器.这是因为只有 JIT 编译器对处理器架构有足够的了解才能决定将方法内联是否合适,因为这是指令流水线和缓存大小之间的权衡.

No you can't. Even more, the one who decides on inlining isn't VS compiler that takes you code and converts it into IL, but JIT compiler that takes IL and converts it to machine code. This is because only the JIT compiler knows enough about the processor architecture to decide if putting a method inline is appropriate as it’s a tradeoff between instruction pipelining and cache size.

因此,即使在 .NET Reflector 中查找也无济于事.

So even looking in .NET Reflector will not help you.