My
first question is related to the size of the executable.
I am trying to move over to CB from VS, as i feel more comfortable with the CB's IDE.
I have been playing with this IDE for a few days, but i have a few performance related questions
regarding the mingw compiler.
First of all, a simple console app with mingw generates about 6 kb filesize, though when including <iostream>
it jumps up to 270 kb, i have gone over all of the flags in the linker to see if i can reduce the file size but with no success.
And by looking at the exe in hex i see that it includes most standard iostream functions that i am not even using in my
test app, like free(), memset() etc. While VC8 generates the same exe at around 50 kb.
Only thing i can think of is that perhaps VC links to a core windows platform .dll and hides away allot of data from the executable,
while mingw embed everything in the exe for good compatibility.
Though a friend of mine that just uses mingw & a makefile(no IDE), can make 100 times larger programs and keep the size at 20-30 kb.
We went over the settings i used in CB with mingw and even with identical linker settings, with optimizers etc mine was still 270 kb.
example
// ~270 KB
#include <iostream>
int main()
{
printf("This is a test\n");
return 0;
}
// ~6 kb
int main()
{
return 0;
}
My
second question is related to performance speed.
As it is very important for me , that when i am moving away from VS i want to
maintain about the same computation performance in my programs, so i did a few tests.
An example, the code bellow took about 11 sec to complete with VS's compiler, with default release
configurations, and in CB with MingW with the best combination of performance settings, in release mode
the best i could get was about 14 sec.
#include <iostream>
#include <conio.h>
#include <Windows.h>
#include <Mmsystem.h>
inline float InvSqrt (float x)
{
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}
int main()
{
FILE *fp = fopen("Out.txt","wb");
if(!fp)
return 0;
UINT StartTime = timeGetTime();
for(UINT i = 0; i < 10000000; i++)
fprintf(fp,"%f",InvSqrt(50));
UINT EndTime = timeGetTime();
printf("%f\n",((float)(EndTime - StartTime) / 1000));
fclose(fp);
_getch();
return 0;
}
I don't mean to be a performance geek, but such a significant difference in small scale tests deeply concerns me.
I have heard allot of good info on MingW's capabilities so i wanted to make this post to see if there is something i could
do any differently.
Thanks,
Fred