Page 1 of 3
Why does it take time to compile?
Posted: Wed Feb 22, 2012 7:53 am
by jesperbrannmark
Hi.
I just got a new i7 laptop (so 5400 rpm hd), and compared to my macbook air core2duo (ssd) it compiles in about the same time.
The compile time actually bugs me a lot.
Why does it take time?
Is it because of CPU usage? (not so sure, because the i7 would be faster in that case)
Or is it because of disc use? (not so sure either, because the macbook would be faster in that case)
Is there any smart way of getting the compiletime down?
Ramdisc? Use multiple cores in the compiler? Any ideas?
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 8:52 am
by Thorium
How big is the source you want to compile?
I never had problems with the compile speed of PB, it's actualy pretty fast because it does not do a lot of optimizations to the code and compiles in a single pass.
You could try to split your project in modules that you compile to DLL's or libs, so you dont need to compile the whole project every time you change something.
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 8:57 am
by jesperbrannmark
My code is 30k lines or so, devided into 12 files thats included. There is also some includes. End .exe file is about 2-3mb.
Don't get me wrong. Its not slow. Visual studio is the type where you can put your coffee maker on, wait for it, drink your coffe and then your application is done. PB is more like you can look at the newspaper, facebook and PB forum and then your application is done.
Gfabasic32 that i used to work with always compiled in no time (nomatter size of exe or includes) - but that had all files at hand (no need to load a compiler, no need to write a ASM file, no need to reload the includes)
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 9:42 am
by gnasen
My project is currently around 30-35k lines of code and it compiles in max. 3 seconds. And I only use a low budget notebook.
There seems something wrong with your setup?
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 10:42 am
by Fred
do you include some binary data to end up to 2-3 mega for 30k lines ?
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 11:13 am
by jesperbrannmark
Yep. Its about a dussin PB files and then several small png files.
I might be extremely fast reading the newspaper... I am not in any way dissatisfied, this is more a general discussion for me - is there any way of making it faster?
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 2:45 pm
by Kuron
Exaggerated compile times are usually down to a nefarious AV (or other such program) trying to do things it should not be doing.
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 4:51 pm
by skywalk
What compiler options do you use?
I've noticed small differences with and without unicode selected.
And if it is your 1st compile after opening IDE.
And if debugger is on.
3 - 10 sec for 20k lines on Windows 7 SP1 x86.
Same code on XP compiles faster in general regardless of slower general processor.
So, it definitely implies a lot of interaction with Antivirus and OS and hard drive access times...
Still, you must be quite the speed reader to finish a newspaper before compile time.

Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 6:15 pm
by Thorium
jesperbrannmark wrote:is there any way of making it faster?
As i wrote, split it in modules you compile seperatly.
Instead of including many includes, make DLL's of them so they are not compiled if you compile the main source.
Thats the only way i can think of to speed it up.
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 7:15 pm
by Polo
I'm not sure DLL are the way to go, I would never do that anyway.
However, this can be a great way to improve PB's compiler! compile to static libs each files, and only re compile it if the file has change

Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 7:46 pm
by Thorium
Polo wrote:I'm not sure DLL are the way to go, I would never do that anyway.
However, this can be a great way to improve PB's compiler! compile to static libs each files, and only re compile it if the file has change

On the compiler side it even doesnt need to be static libs, just object files. It's a common compile speed optimization used by a lot of compilers.
However that does not help jesperbrannmark because he cant change the compiler.
And why not use DLL's?
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 7:50 pm
by Polo
Thorium wrote:Polo wrote:I'm not sure DLL are the way to go, I would never do that anyway.
However, this can be a great way to improve PB's compiler! compile to static libs each files, and only re compile it if the file has change

On the compiler side it even doesnt need to be static libs, just object files. It's a common compile speed optimization used by a lot of compilers.
However that does not help jesperbrannmark because he cant change the compiler.
And why not use DLL's?
True, but if Fred do that in the future that'd be brilliant!

I'd not use DLLs just because it means bigger overall size, plus I'd rather have a single file, it's just cleaner and look/is less bloated

Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 7:58 pm
by Thorium
Polo wrote:
True, but if Fred do that in the future that'd be brilliant!

I'd not use DLLs just because it means bigger overall size, plus I'd rather have a single file, it's just cleaner and look/is less bloated

Yes, but i am sure Fred does know this technic.
So the question is how hard is it realy to implement. I guess it's not that easy because of the procedural nature of PB. On a OOP language it should be much easier to implement as you do have objects that can be seperated from each other. On PB everything can access everything from everywhere. So i guess it's a lot harder to build reusable object files out of the single PB files.
But i am not a expert on compiler development, i could be wrong.
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 8:27 pm
by Polo
Same here, I don't know anything about that, but if that's possible that'd be a nice thing to have (although I'm much more waiting for the Cocoa subsystem on Mac than anything else

)
Re: Why does it take time to compile?
Posted: Wed Feb 22, 2012 8:41 pm
by Danilo
Thorium wrote:I guess it's not that easy because of the procedural nature of PB.
PB is like C in this case, but PureBasic always compiles one big source (with includes),
whereas C compilers can compile separate modules/files.
With modules only changed sources need to get compiled again to give the linker the latest .obj/.lib files for linking.
I think module support has already been requested.