+ 6

Different C++ compiler behaviors?

I executed a C++ program in an offline Turbo C++ compiler first. It took 342+ seconds to execute. When the Java version of the code executed in 8 seconds in an online compiler, I thought that C++ is slower. I even made a post on that (https://www.sololearn.com/discuss/299927/?ref=app). Later, I executed the code in 2 online GCC C++ compilers. One of them took 10 seconds but the other took only one second. These values stayed the same in multiple trails. Any idea on why the different behaviors of compilers?

8th Apr 2017, 4:59 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
9 Answers
+ 10
Turbo C++ is old technology...very old. I wonder if Borland still exists.
8th Apr 2017, 5:10 PM
Karl T.
Karl T. - avatar
+ 9
Online compilers are subject to internet traffic I would guess. Did you make several tests?
8th Apr 2017, 5:07 PM
Karl T.
Karl T. - avatar
+ 7
You're not going to get comparable results by using online compilers. You can't reliably say that the difference in runtime is the fault of the different compilers; it's most likely due to the differing specifications of the machines that the code is being executed on, and the load they're under at any given time from other users. To perform proper benchmarks, you need to run all tests on the same machine under the same conditions.
8th Apr 2017, 5:05 PM
Squidy
Squidy - avatar
+ 7
@Dimas : Thanks. But, there is not much difference in execution times with different compilers according to the page you linked.
9th Apr 2017, 11:54 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 5
@Squidy : I am wondering why the offline Turbo C++ compiler took 343 seconds. Is it that slower?
8th Apr 2017, 5:07 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 5
@Helioform : Executed the same code in those 2 online compilers 10 times and got almost same results.
8th Apr 2017, 5:08 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 5
@Helioform : I used only online compilers till now. When I was suggested to use an offline compiler (in the post I linked), I downloaded that. Then I found in Wikipedia that Turbo C++ is discontinued. But I didn't read anywhere that it's slow.
8th Apr 2017, 5:14 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 1
use clang instead of g++
8th Apr 2017, 5:20 PM
Dimas Fajar
Dimas Fajar - avatar