2011-06-07 65 views
2

我想比較在.NET和Mono 2.10.2(Windows 7,64位)上運行的特定F#基準測試的性能。我從基準遊戲中採取了Spectral-Norm benchmark,遵循了使用System.Diagnostics.StopWatch進行基準測試的傳統SO建議,並在this link處添加了第4,89-90和93-95行。我在Visual Studio 2010中編譯了此代碼(對於運行時4.0,不是客戶端配置文件,任何CPU,優化代碼和尾部調用均打開)。編譯後的代碼在.NET上運行得很好(包括VS內部),但是當我在Mono上運行帶有「mono shootout_spectralnorm.exe」的.exe時,出現以下錯誤(在fssnip.net鏈接中重複):在Mono上運行F#基準測試時發生運行時異常

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行,與基準測試的時間部分有關)時,錯誤在單聲道上消失,就像它在MS .NET上一樣。這只是讓我困惑。我將VS中的所有引用程序集設置爲在本地複製,因此它們應該對Mono可見,但GAC中的不同程序集可能存在與本地文件夾中的程序集名稱相同的一些優先問題。有沒有人遇到過這個問題或類似的問題,特別是在Windows Mono上?如果是這樣,或者你認爲你知道如何解決這個問題,我希望你能幫我解決它。

回答

3

參考程序集不會(通常)有代碼 - 它們只是API簽名(足夠的信息供編譯器在設計時/編譯時引用它們)。您需要複製運行時程序集,而不是引用程序集,以便運行它。 (你會經常發現在GAC運行時組件。)

+0

所以C:\ Program Files文件(x86)的\參考大會\微軟\ FSharp \ 2.0 \運行\ V4.0 \ FSharp.Core.dll是一個運行時組件和文件VS複製到該目錄是參考彙編? – notostraca 2011-06-07 03:35:43

+0

你是對的!我正在使用引用程序集,並將運行時程序集手動複製到應用程序的目錄中,這對Mono來說是個竅門。現在我只需要弄清楚爲什麼Mono在這個基準測試中花費了30倍的時間... – notostraca 2011-06-07 03:46:24

+0

@notostraca >>現在我只需要弄清楚爲什麼Mono在這個基準測試中花費了30倍的時間。<< Somethings wrong with that http:/ /stackoverflow.com/questions/6260241/runtime-exceptions-when-running-an-f-benchmark-on-mono/6267814#6267814 – igouy 2011-06-07 21:42:54

0

這裏是三圍FSharp-2.0.0.0 譜範#2(英特爾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 

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

相關問題