Hi,

I am currently running some C++ code in Windows. I am using Code::Blocks with mingw therefore using the gcc compiler. Can anyone tell me, is thespeed of execution of the final .exe file dependant on the compiler? e.g. will the speed change if I use Visual C++ 2008 Express Edition to compile my code?

And if it does change, which will give a faster execution speed?

Also, will the execution speen change if I compile the code in Linux instead of Windows.

Thanks in advance.

Kind regards,
Audette

Can anyone tell me, is thespeed of execution of the final .exe file dependant on the compiler? e.g. will the speed change if I use Visual C++ 2008 Express Edition to compile my code?

Probably, yes.

And if it does change, which will give a faster execution speed?

Depends on what code you're trying to compile. Gcc will compile some things better, and Visual Studio will compile other things better. There's no real 'rule' to go by.

Also, will the execution speen change if I compile the code in Linux instead of Windows.

Probably yes.

But the real question is: why do you want to know this? How big is your code that you need to know which compiler compiles the fastest?
It's a better idea to review your code and see if there's room for improvement rather then change your compiler.

There are options in the "Compiler" section in Code::blocks to make a faster executable. This will result in a longer compilation, but the program will be faster.

On Visual Studio, you can compile release and debug versions. Release versions are faster, because they don't contain debugging symbols (in the generated assembly code) required to debug an application in the debug version. The equivalent (debug and release) may exist in Code::Blocks.

And, as always, the speed of the execution mainly depends on what you do in the program. Are you using slow library functions? Slow and very greedy algorithms?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.