Do fluent interfaces significantly impact runtime performance of a .NET application?

好久不见. 提交于 2019-12-04 02:49:30

Generally speaking, objects with a very small lifetime are exactly the kind of objects that the GC deals most efficiently with, because most of them will be dead at the time the next minor collection runs -- and on any decent GC implementation, the cost of a minor collection is proportional to the total size of live objects. Thus, short-lived objects cost very little, and their allocation means only bumping a pointer up, which is fast.

So I would say: probably no significant performance impact.

Thomas is quite correct that generational GC is optimized for exactly this allocation and collection of short-lived objects. However, functional languages like OCaml have GCs that are much more heavily optimized for this than .NET is and, yet, they still go to great lengths to avoid this situation in the equivalent circumstance of applying multiple arguments to a curried function. Specifically, they use a technique called big-step semantics where the compiler removes all of the intermediates at compile time so the GC never sees any of this.

On .NET, value types may well let you solve this problem yourself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!