Why is .NET faster than C++ in this case?

后端 未结 13 1480
长发绾君心
长发绾君心 2021-02-02 00:59

Make sure you run outside of the IDE. That is key.

-edit- I LOVE SLaks comment. \"The amount of misinformation in these answers is staggering.\" :D

13条回答
  •  礼貌的吻别
    2021-02-02 01:31

    Not saying that's the issue, but you may want to read How to: Use the High-Resolution Timer

    Also see this... http://en.wikipedia.org/wiki/Comparison_of_Java_and_C%2B%2B#Performance

    Several studies of mostly numerical benchmarks argue that Java could potentially be faster than C++ in some circumstances, for a variety of reasons:[8][9] Pointers make optimization difficult since they may point to arbitrary data, though many C++ compilers provide the C99 keyword restrict which corrects this problem.[10] Compared to C++ implementations which make unrestrained use of standard implementations of malloc/new for memory allocation, implementations of Java garbage collection may have better cache coherence as its allocations are generally made sequentially. * Run-time compilation can potentially use additional information available at run-time to optimise code more effectively, such as knowing what processor the code will be executed on.

    It's about Java but begins to tackle the issue of Performance between C runtimes and JITed runtimes.

提交回复
热议问题