In .Net, when if ever should I pass structs by reference for performance reasons?

后端 未结 4 867
广开言路
广开言路 2020-12-29 07:23

In my C# application, I have a large struct (176 bytes) that is passed potentially a hundred thousand times per second to a function. This function then simply takes a point

4条回答
  •  清歌不尽
    2020-12-29 07:41

    I did some very informal profiling, and the results indicate that, for my particular application, there is a modest performance gain for passing by reference. For by-value I got about 10,050,000 calls per second, whereas for by-reference I got about 11,200,000 calls per second.

    Your mileage may vary.

提交回复
热议问题