编辑:
似乎已经有很多关于这个问题的问题我找不到了(如果你真的用“F#”这个词搜索任何东西都没有结果). here的一个好处是以下答案:
F# provides some performance-related
features that can make a difference.Firstly,the implementation of
delegates on .NET is currently quite
inefficient and,consequently,F# uses
its own FastFunc type for
high-performance first-class
functions.Secondly,F# uses .NET Metadata to
convey inline functions so that they
can be exported across APIs and,of
course,that can dramatically improve
performance in certain circumstances.Finally,pattern matching can be
extremely laborIoUs to express in C#
because the language lacks pattern
matching but it is almost impossible
to maintain optimized C# code
equivalent to many non-trivial pattern
matches. In contrast,the F# compiler
aggressively optimizes pattern matches
during compilation.Conversely,the C# compiler is better
at optimizing loops using IEnumerables
and is better at optimizing
computations over value types (e.g.
complex arithmetic).Cheers,Jon Harrop.
解决方法
以下是使用不同语言实现的单线程算法的一些性能结果(基准激活函数方法用于神经网络):
C#:
10^7 iterations using Sigmoid1() took 3899,1979 ms 10^7 iterations using Sigmoid2() took 411,4441 ms
纯C:
10^7 iterations using sigmoid1: 628 ms 10^7 iterations using sigmoid2: 157 ms
F#:
10^7 iterations using sigmoid1: 588.843700 ms 10^7 iterations using sigmoid2: 156.626700 ms
原文地址:https://www.jb51.cc/csharp/99843.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。