Why does it take time to compile?

Everything else that doesn't fall into one of the other PB categories.
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Why does it take time to compile?

Post 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?
Thorium
Addict
Addict
Posts: 1314
Joined: Sat Aug 15, 2009 6:59 pm

Re: Why does it take time to compile?

Post 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.
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Why does it take time to compile?

Post 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)
gnasen
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 24, 2008 12:21 am

Re: Why does it take time to compile?

Post 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?
pb 5.11
Fred
Administrator
Administrator
Posts: 18553
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Why does it take time to compile?

Post by Fred »

do you include some binary data to end up to 2-3 mega for 30k lines ?
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Why does it take time to compile?

Post 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?
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: Why does it take time to compile?

Post 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.
Best wishes to the PB community. Thank you for the memories. ♥️
User avatar
skywalk
Addict
Addict
Posts: 4318
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Why does it take time to compile?

Post 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. :wink:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Thorium
Addict
Addict
Posts: 1314
Joined: Sat Aug 15, 2009 6:59 pm

Re: Why does it take time to compile?

Post 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.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Why does it take time to compile?

Post 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 :)
Thorium
Addict
Addict
Posts: 1314
Joined: Sat Aug 15, 2009 6:59 pm

Re: Why does it take time to compile?

Post 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. :wink:

And why not use DLL's?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Why does it take time to compile?

Post 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. :wink:

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 :)
Thorium
Addict
Addict
Posts: 1314
Joined: Sat Aug 15, 2009 6:59 pm

Re: Why does it take time to compile?

Post 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.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Why does it take time to compile?

Post 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 :) )
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Why does it take time to compile?

Post 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.
Post Reply