Math optimization in C#

后端 未结 25 2388
悲&欢浪女
悲&欢浪女 2020-12-07 10:25

I\'ve been profiling an application all day long and, having optimized a couple bits of code, I\'m left with this on my todo list. It\'s the activation function for a neural

25条回答
  •  甜味超标
    2020-12-07 11:12

    I realize that it has been a year since this question popped up, but I ran across it because of the discussion of F# and C performance relative to C#. I played with some of the samples from other responders and discovered that delegates appear to execute faster than a regular method invocation but there is no apparent peformance advantage to F# over C#.

    • C: 166ms
    • C# (delegate): 275ms
    • C# (method): 431ms
    • C# (method, float counter): 2,656ms
    • F#: 404ms

    The C# with a float counter was a straight port of the C code. It is much faster to use an int in the for loop.

提交回复
热议问题