Re: C++ /clr vs. unmanaged C++

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance





"Escri" <Escri@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:D6C1B83D-9699-44F3-A48B-F9A35A1399C4@xxxxxxxxxxxxxxxx
Hi,

If I build a (MFC) application with /clr but I don't add any C++/CLI code,
only pure C++ code, will there be differences in runtime compared with
building an unmanaged application?

Yes. In general the /clr version will use more memory and start slower. The throughput may or may not be similar.


As far as I understand, the CLR will take the /clr application, JIT compile
it and pass it to the native system. So the only difference would be when and
who generate the machine code. Is this correct?

Essentially, but the JIT compiler is also responsible for optimization. The JIT can do more cross-module optimization than the native C++ compiler, but the C++ compiler considers a lot more optimizations, only some of which are used when generating IL. In general the native code generated by the C++ compiler will be better optimized than the JIT. Also, when compiling /clr without using .NET features, you don't take advantage of the .NET memory management scheme (which is generally faster than the default C++ allocators) which usually compensates for the reduced optimization.

Overall I expect you'll see a performance penalty enabling /clr.


Thanks in advance

.



Relevant Pages

  • Re: Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... what experienced programmers do, ... optimization, ... Thugs" ad nauseum fits that a lot more closely than discussing compiler ... be modified outside a loop, and guessing ...
    (comp.programming)
  • Re: What Delphi users really want (other than bugfixes)
    ... > Maybe you can't directly access SIMD from .NET code but what do you make ... Still waiting for any of that "JIT-only optimization" to happen ... in the real world and have it beat an AOT compiler... ... I would be more impressed if the JIT was able to overtake ye olde ...
    (borland.public.delphi.non-technical)
  • long(!) Re: need help on CFLAGS in /etc/make.conf please
    ... For example, MPlayer sets this high on purpose, so GCC will actually ... and the K&R compiler would've known exactly the kind of optimization we wanted. ... >> A msg from Richard Coleman, taken together with the GCC 3.x Known Bugs ...
    (freebsd-questions)
  • Re: SETF and variable issues in Self Similar program.
    ... The way to get a compiler to optimize a tail-call ... call optimization turned on. ... It changes the semantics of the language in a big way. ... In Common Lisp it has to interact with condition handling, ...
    (comp.lang.lisp)
  • Re: Programming languages
    ... >> execution time, ... That's not a good candidate for optimization. ... if there is comething the compiler ... António> programmers and those can't cope with anything else than ...
    (sci.lang)