Benchmark C++ vs Java, Unrealistic results

后端 未结 3 1179
闹比i
闹比i 2021-01-20 22:06

I did a simple test, I know C++ is faster but the results of my test is unrealistic.

C++ code is:

#include 
#include          


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-20 22:38

    First of all, you probably don't want the respective print functions to be part of your benchmark unless you really care how fast those are.

    There's not a straight answer as to whether Java or C++ is faster...it depends. Java can be faster when the compiler can do some optimizations that would not be available for C++. So it depends on what specifically you are doing and what the compiler options are.

提交回复
热议问题