我在C#中创建了一个控制台应用程序,在windows / .NET上运行它比在linux / mono或windows / mono上快5倍。 该应用程序将一些二进制文件编码为文本格式(JSON)。
我使用:
在linux / mono上分析了应用程序mono --profile=default:stat myconsoleapp.exe
以下是结果的第一部分:
prof counts: total/unmanaged: 32274/25062
23542 72.95 % mono
459 1.42 % System.Decimal:Divide (System.Decimal,System.Decimal)
457 1.42 % System.Decimal:Round (System.Decimal,int,System.MidpointRounding)
411 1.27 % /lib/libz.so.1
262 0.81 % /lib/tls/i686/cmov/libc.so.6(memmove
253 0.78 % System.Decimal:IsZero ()
247 0.77 % System.NumberFormatter:Init (string,double,int)
213 0.66 % System.NumberFormatter:AppendDigits (int,int)
单声道72.95%?单声道内部使用总执行时间的3个季度?
编辑:这是“mono --version”
的结果Mono JIT compiler version 2.4.2.3 (Debian 2.4.2.3+dfsg-2)
Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
TLS: __thread
GC: Included Boehm (with typed GC)
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
答案 0 :(得分:1)
正确。 看起来你的单声道二进制文件的符号被剥离了,所以你没有得到更精确的信息。
我的猜测是,大部分开销都在十进制代码中,并且(可能)在GC中。
对于第一种情况:你使用的单声道版本是什么? IIRC,我们最近修复了该领域的一些性能问题。从svn trunk尝试单声道可能是个好主意。
如果开销来自GC,我们正在实施的新GC应该有帮助。
如果您发布了测试程序的源代码或二进制文件,我们可以确认这两个问题。