在 Mono 上运行 F# 基准测试时出现运行时异常

发布于 2024-11-14 08:02:38 字数 1202 浏览 2 评论 0原文

我正在尝试比较在 .NET 和 Mono 2.10.2(Windows 7,64 位)上运行的特定 F# 基准测试的性能。我采用了 Spectral-Norm 基准测试基准游戏中的 遵循使用 System.Diagnostics.StopWatch 进行 C# 基准测试的传统 SO 建议,并添加了第 4、89-90 行和93-95,位于此链接。我在 Visual Studio 2010 中编译了此代码(对于运行时 4.0,不是客户端配置文件,任何 CPU,打开了优化代码和尾部调用)。编译后的代码在.NET(包括VS内部)上运行得很好,但是当我在Mono上使用“monoshootout_spectralnorm.exe”运行.exe时,我收到以下错误(在fssnip.net链接中重复):

Unhandled Exception: System.TypeInitializationException: An exception was thrown
by the type initializer for System.Diagnostics.Stopwatch ---> System.InvalidPro
gramException: Invalid IL code in System.Diagnostics.Stopwatch:.cctor (): method
body is empty.

--- End of inner exception stack trace ---
at Program.main (System.String[] args) [0x00000] in <filename unknown>:0

奇怪的是,当我删除我添加的行(第 4、89-90 和 93-95 行,与基准测试的计时部分相关)时,错误在 Mono 上消失,并且它的作用只是就像在 MS .NET 上一样。这让我很困惑。我将 VS 中所有引用的程序集设置为本地复制,因此它们应该对 Mono 可见,但 GAC 中与本地文件夹中的程序集同名的不同程序集可能存在一些优先级问题。有没有人遇到过这个问题或类似的问题,尤其是在 Windows Mono 上?如果是这样,或者如果您认为您知道如何解决此问题,我希望您能帮助我解决它。

I am trying to compare the performance of a specific F# benchmark running on .NET and Mono 2.10.2 (Windows 7, 64-bit). I took the Spectral-Norm benchmark from the Benchmarks Game followed the traditional SO advice of using System.Diagnostics.StopWatch for benchmarking C# and added the lines 4, 89-90, and 93-95 at this link. I compiled this code in Visual Studio 2010 (For runtime 4.0, not client profile, any CPU, with optimize code and tail calls turned on). The compiled code runs just fine on .NET (including inside VS), but when I run the .exe on Mono with "mono shootout_spectralnorm.exe" I get the following error (repeated in the fssnip.net link):

Unhandled Exception: System.TypeInitializationException: An exception was thrown
by the type initializer for System.Diagnostics.Stopwatch ---> System.InvalidPro
gramException: Invalid IL code in System.Diagnostics.Stopwatch:.cctor (): method
body is empty.

--- End of inner exception stack trace ---
at Program.main (System.String[] args) [0x00000] in <filename unknown>:0

The strange thing is, when I remove the lines I had added (lines 4, 89-90, and 93-95, which relate to the timing part of the benchmark), the error goes away on Mono, and it acts just like it does on MS .NET. This is just baffling me. I set all of the referenced assemblies in VS to be copied locally, so they should be visible to Mono, but there could be some precedence issue with different assemblies in the GAC that have the same name as the ones in the local folder. Has anyone encountered this issue or a similar one, especially on Windows Mono? If so, or if you think you know how this problem could be fixed, I hope you can help me resolve it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

因为看清所以看轻 2024-11-21 08:02:38

参考程序集(通常)没有代​​码 - 它们只是 API 签名(编译器有足够的信息在设计时/编译时引用它们)。您需要复制运行时程序集,而不是引用程序集才能运行它。 (您经常会在 GAC 中找到运行时程序集。)

Reference Assemblies do not (often) have code - they are API signatures only (enough info for the compiler to reference them at design-time/compile-time). You need to copy the runtime assemblies, not the reference assemblies, in order to run it. (You'll often find the runtime assemblies in the GAC.)

笑饮青盏花 2024-11-21 08:02:38

以下是 FSharp-2.0.0.0 spectral-norm #2 的测量结果(Intel Q6600 四核,MS Vista 32 位)

fsc     CPU s   Elapsed s
500     0.281   0.337
3000    4.883   1.453
5500    15.85   4.212

2.10.2  CPU s   Elapsed s
500     0.343   2.222
3000    4.836   3.361
5500    15.912  6.153

C:/Mono-2.10.2/bin/mono.exe C:/FSharp-2.0.0.0/bin/fsc.exe --platform:x86 
    --optimize+ --out:spectralnorm.exe spectralnorm.fsharpmono-2.fs

C:/Mono-2.10.2/bin/mono.exe --gc=sgen spectralnorm.exe 5500

现在 MS Vista 演示上的基准游戏光谱范数,包括 Mono 上的 F#

Here are measurements for FSharp-2.0.0.0 spectral-norm #2 (Intel Q6600 quad-core, MS Vista 32 bit)

fsc     CPU s   Elapsed s
500     0.281   0.337
3000    4.883   1.453
5500    15.85   4.212

2.10.2  CPU s   Elapsed s
500     0.343   2.222
3000    4.836   3.361
5500    15.912  6.153

C:/Mono-2.10.2/bin/mono.exe C:/FSharp-2.0.0.0/bin/fsc.exe --platform:x86 
    --optimize+ --out:spectralnorm.exe spectralnorm.fsharpmono-2.fs

C:/Mono-2.10.2/bin/mono.exe --gc=sgen spectralnorm.exe 5500

Now the benchmarks game spectral-norm on MS Vista demo, includes F# on Mono.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文