提高性能C ++ / C# [英] Improving performance C++/C#

查看:61
本文介绍了提高性能C ++ / C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于历史原因,我在我的类库中将C#和C ++托管/非托管代码

混合在一起。

但我更喜欢将代码移植到C#中它编译速度更快,语法更可读,因此我可以在更短的时间内完成更多工作。


现在最重要的问题是,我会获得/失去性能如果我将托管C ++类移植到C#类,我可以创建纯托管代码吗?我/ b $ b不能同时移植所有类,端口太多,时间不够。


我使用的是C ++和C#标准版2003.对于C ++没有速度优化是可能的,但是由于C#使用.NET框架中的C#编译器,我可能会以这种方式获得更快的速度吗?

解决方案



托管C ++和C#理论上应该编译成相同的(或等价的)

MSIL,所以你应该看不到速度差异。在这两种情况下,JIT编译器在运行时都会执行优化。但是,我并不完全确定与VC ++的编译器优化设置的关系是什么。当然,对于非托管代码,他们可以产生巨大的差异。他们可能对托管代码产生

的影响,但我不知道。如果您在非托管C ++中执行严重的数据运算,如果您将
转换为C#,则可能会遇到性能损失。话虽如此,编码很好,性能问题应该是可以忽略不计的。根据我自己的经验,调试版本(没有

优化)和发布版本(C ++编译器和链接器优化以及

JIT优化)之间存在差异,但是在处理器密集型工作的区域(通过管理和非管理功能的混合物来完成)中,它往往会显而易见。

。 />

我认为这取决于你的应用程序 - 开发的简易性比你挤出性能更有价值吗?你猜不到,直到你已经尝试了C#端口,我才会知道。也许比我更了解的人

可以告诉你(和我!)C ++编译器优化对于与bIT编译器组合的
有什么影响。


史蒂夫


" Olaf Baeyens" <醇********** @ skyscan.be>在消息中写道

news:41 ********************** @ news.skynet.be ...

由于历史原因,我将C#和C ++托管/非托管
代码混合在我的类库中。
但我更喜欢将代码移植到C#,因为它编译速度更快,语法
更具可读性,因此我可以在更短的时间内完成更多工作。

现在最重要的问题是,我是否会获得/失去性能,因为我创建纯托管代码,如果我将托管C ++类移植到C#类?
我无法一次移植所有类,端口太多,时间不够。

我使用的是C ++和C#标准版2003.对于C ++,没有速度优化是
可能,但是因为C#使用.NET框架中的C#编译器,所以我用b $ b可能会有更快的速度吗?



Steve McLellan写道:



管理的C ++和C#理论上应该编译成相同的(或等效的)MSIL,所以你应该看不到速度差异。在这两种情况下,JIT编译器都会在运行时执行优化。但是,我不完全确定与VC ++的编译器优化设置的关系。当然,对于非托管代码,它们可以产生巨大的差异。它们可能会对托管代码产生影响,但我不知道。如果你在非托管C ++中执行严重的数字运算,如果你转换为C#,你可能会发现性能损失。话虽如此,编码良好,性能问题应该可以忽略不计。根据我自己的经验,调试版本(没有优化)和发布版本(C ++编译器和链接器优化以及JIT优化)之间的区别存在差异,但它往往在<处理器密集型工作的区域(由管理和非托管功能混合完成)。

我认为这取决于您的应用程序 - 是易于开发对于你比挤出性能更有价值?在你尝试使用C#端口之前,你永远都不会知道。也许比我更了解的人
可以告诉你(和我!)C ++编译器优化在与JIT编译器组合中的作用。



VC ++是并且将来会更多地生成比VC#更优化的代码




通常比C#快25%的代码。即将推出的优化仅适用于C ++的
,包括PGO和OpenMP扩展等支持对关键应用程序产生严重的影响。

还提供了C#/ CLI缺陷与即将推出的C ++ / CLI相比,

我无法理解为什么要从C ++转移到C#。


一些引用:

C ++ / CLI(vs C#/ CLI)
http://www23.brinkster.com/noicys/cppcli.htm
http://microsoft.sitestream.com/Tech...V333_Sutte.ppt
http://www.accu.org/conference/prese..._(主题演讲)。 pdf


面向VC ++的优化:

http://msdn.microsoft.com/msdntv /epi...G/manifest.xml
http://msdn.microsoft.com/visualc/de...timization.asp


-

Ioannis Vranos


" Ioannis Vranos" < iv*@guesswh.at.grad.com>在消息中写道

新闻:O7 ************** @ TK2MSFTNGP15.phx.gbl ...

Steve McLellan写道:< blockquote class =post_quotes>



VC ++将来会更多,产生比VC#更优化的代码。
通常比C#快25%的代码。即将推出的优化仅适用于C ++,包括PGO和OpenMP扩展等支持对关键应用程序产生严重影响。

与即将推出的C ++ / CLI相比,还提供了C#/ CLI缺陷,
我无法理解为什么要从C ++转移到C#。







我记得以前争论过这个,所以我不会重复它:-)那个信息'

很高兴知道 - 这意味着C ++和C#之间的权衡(执行

速度而不是更快(或更简单)的开发)可能仍然会保留
。我不知道PGO只适用于C ++,这很有意思。


谢谢,


Steve

Because of historical reasons, I have both C# and C++ managed/unmanaged code
mixed together in my class library.
But I prefer to port code to C# since it compiles faster and the syntax is
much more readable so I can do more in less time.

The big question now, will I gain/lose performance, given the fact that I
create pure managed code, if I port the managed C++ classes to C# classes? I
cannot port all the classes at once, too much to port, not enough time.

I use the C++ and C# standard edition 2003. For C++ no speed optimizing is
possible, but since C# uses the C# compiler from the .NET framework, I might
have faster speed this way?

解决方案

Hi,

Managed C++ and C# SHOULD theoretically compile to the same (or equivalent)
MSIL, so you should see no speed differences. In both cases, optimization is
performed by the JIT compiler at runtime. However, I''m not entirely sure as
to the relationship with VC++''s compiler optimization settings. Certainly
for unmanaged code they can make an enormous difference. They could have an
effect on managed code, but I don''t know. If you''re performing serious
number crunching in the unmanaged C++ you may find a performance hit if you
convert to C#. Having said that, coded well, performance problems should be
neglible. From my own experience, the difference between a debug build (no
optimization) and a release build (C++ compiler and linker optimization and
JIT optimization) there is a difference, but it tends to be noticeable in
the areas where there''s processor intensive work going on (which is done by
a mixture of managed and unmanaged functions).

I suppose it depends on your app - is ease of development more valuable to
you than squeezing out performance? You''ll never really know until you''ve
tried the C# ports, I guess. Maybe someone more knowledgeable than myself
can inform you (and me!) what effect the C++ compiler optimizations do in
combination with the JIT compiler.

Steve

"Olaf Baeyens" <ol**********@skyscan.be> wrote in message
news:41**********************@news.skynet.be...

Because of historical reasons, I have both C# and C++ managed/unmanaged code mixed together in my class library.
But I prefer to port code to C# since it compiles faster and the syntax is much more readable so I can do more in less time.

The big question now, will I gain/lose performance, given the fact that I
create pure managed code, if I port the managed C++ classes to C# classes? I cannot port all the classes at once, too much to port, not enough time.

I use the C++ and C# standard edition 2003. For C++ no speed optimizing is
possible, but since C# uses the C# compiler from the .NET framework, I might have faster speed this way?



Steve McLellan wrote:

Hi,

Managed C++ and C# SHOULD theoretically compile to the same (or equivalent)
MSIL, so you should see no speed differences. In both cases, optimization is
performed by the JIT compiler at runtime. However, I''m not entirely sure as
to the relationship with VC++''s compiler optimization settings. Certainly
for unmanaged code they can make an enormous difference. They could have an
effect on managed code, but I don''t know. If you''re performing serious
number crunching in the unmanaged C++ you may find a performance hit if you
convert to C#. Having said that, coded well, performance problems should be
neglible. From my own experience, the difference between a debug build (no
optimization) and a release build (C++ compiler and linker optimization and
JIT optimization) there is a difference, but it tends to be noticeable in
the areas where there''s processor intensive work going on (which is done by
a mixture of managed and unmanaged functions).

I suppose it depends on your app - is ease of development more valuable to
you than squeezing out performance? You''ll never really know until you''ve
tried the C# ports, I guess. Maybe someone more knowledgeable than myself
can inform you (and me!) what effect the C++ compiler optimizations do in
combination with the JIT compiler.


VC++ is and will even more in the future, produce more optimised code
than VC#.

Typically 25% faster code than C#. Upcoming optimisations available only
for C++ including PGO and OpenMP extensions etc support have serious
impact for critical applications.
Also provided C#/CLI deficiencies in comparison to the upcoming C++/CLI,
I cannot understand why one should move from C++ to C#.

Some references:
C++/CLI (vs C#/CLI)

http://www23.brinkster.com/noicys/cppcli.htm
http://microsoft.sitestream.com/Tech...V333_Sutte.ppt
http://www.accu.org/conference/prese..._(keynote).pdf

VC++ oriented optimisations:

http://msdn.microsoft.com/msdntv/epi...G/manifest.xml
http://msdn.microsoft.com/visualc/de...timization.asp

--
Ioannis Vranos


"Ioannis Vranos" <iv*@guesswh.at.grad.com> wrote in message
news:O7**************@TK2MSFTNGP15.phx.gbl...

Steve McLellan wrote:

Hi,


VC++ is and will even more in the future, produce more optimised code
than VC#.

Typically 25% faster code than C#. Upcoming optimisations available only
for C++ including PGO and OpenMP extensions etc support have serious
impact for critical applications.
Also provided C#/CLI deficiencies in comparison to the upcoming C++/CLI,
I cannot understand why one should move from C++ to C#.



Hi,

I remember arguing about this before so I won''t rehash it :-) That info''s
good to know - it means that the tradeoff between C++ and C# (execution
speed rather than faster (or simpler) development) will probably still
remain. I didn''t know that PGO was only for C++, that''s interesting to note.

Thanks,

Steve


这篇关于提高性能C ++ / C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆