受管理的c ++比普通的c ++或c#快吗? [英] Is managed c++ faster than normal c++ or c#?

查看:105
本文介绍了受管理的c ++比普通的c ++或c#快吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用托管的c ++来构建资源密集型应用程序(主要是游戏),但是考虑到它们都是托管的,因此不确定它是否比c#更快.有谁知道这两种语言中的哪一种更快(我不介意任何统计数据).

还想知道与普通的ANSI c ++相比,托管c ++是否会遭受很多性能困扰.我希望非托管(编写良好)的代码会更好.因为所有托管内容都在.net框架/运行时下运行.


您可能会问错问题.

用您最熟悉的语言编写良好(且速度更快)的代码总是比较容易.

如果您对C ++感到满意,那么问题是:

您是否需要垃圾收集?

如果您是编程游戏,您是否可以容忍垃圾回收的不确定性,还是会在某个时候影响实时性能?

您定位到哪个平台?编译到CLR会帮助您选择平台还是阻碍您?如果您要针对没有CLR的平台,那么本机C ++更可移植.如果要定位Windows Phone,建议使用CLR(必需?).

您在谈论什么样的资源?图形?视频?声音的?您将使用什么框架/库来操纵它们?这些框架/库是否为托管或非托管代码提供了更好的支持/接口?除非您要使用自己的库/框架来操纵这些资源,否则可能会最影响您的性能并决定您的选择.


我"我看过一篇文章,其中说C#使用通用优化器,但是C ++/CLI使用特殊的C ++/CLI优化器,在某些情况下可以使代码比C#更快.抱歉,不知道如何找到它……这可能是需要订阅的期刊,也许是Dr.Dobbs ...

—SA


I want to use managed c++ to build resource intensive applications (games mostly) but am not sure if its faster than c# considering the fact that they are both managed. Does anyone know which of the two languages is faster ( I wouldn''t mind any statistical data ).

Also wanted to know if managed c++ suffers a lot of performance as compared to normal ANSI c++

解决方案

I would expect unmanaged (written well) code is better.... as all the managed stuff runs under the .net framework/runtime.


You might be asking the wrong question.

It is always easier to write good (and faster) code in the language you are most familiar with.

If you are comfortable with C++, then the questions are:

Do you want/need garbage collection?

If you are programming games can you tolerate the non-deterministic nature of garbage collection, or will that impact real-time performance at some point?

What platform(s) are you targeting? Does compiling to the CLR help you with your choice of platforms or hinder you? If you want to target platforms that don''t have CLR then native C++ is more portable. If you want to target Window phones, then I think CLR is recommended (required?).

What sort of resources are you talking about? Graphics? Video? Audio? What frameworks / libraries are you going to use to manipulate them? Do those frameworks / libraries offer better support / interfaces for managed or unmanaged code? Unless you are rolling your own library/framework for manipulating those resources, then that''s probably going to be the thing that most influences your performance and also dictates your choice.


I''ve seen the article which says that C# uses generic optimizer, but C++/CLI uses a special C++/CLI optimizer which can make the code faster then C# in certain situations. Sorry, don''t know how to find it… It could be a journal requiring subscription, maybe Dr.Dobbs…

—SA


这篇关于受管理的c ++比普通的c ++或c#快吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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