Re: precompiled headers and Sun Studio 10...

From: Paul Floyd (root_at_127.0.0.1)
Date: 09/24/05


Date: 24 Sep 2005 20:42:06 GMT

On Wed, 21 Sep 2005 22:17:37 +0200, Trond Norbye <trond.norbye@gmail.com> wrote:
> I am currently trying to improve compile-time performance by introducing
> precompiled headers, but my tests so far have not given the expected
> results. Instead of a reduced compile time, I am getting an increased
> compile time.
>
> In my test I created a file called pch.cpp with the following content:
>
> #include "pch.h"
>
> And I compiled the file with:
>
> $(COMPILE.cc) -xpch=collect:pch -xpchstop=pch.h pch.cpp
>
> In pch.h I added all of the header files that I used in the 6 files I
> was going to compile. This might not be the best test, since it was only
> one or two header files that was common for all of the files, but I
> would expect a small decrease of compile time at least).

I'd expect an increase in compile time for the first build (and probably
each time you touch a header), but decreased build times when you touch
implementation files.

I did a few tests and found a small speed gain, but that it probably
took me longer to optimize finding which headers gave me that gain than
I would ever benefit from it.

My take on this is that PCH can be a big benefit on Wind32, where you
often include windows.h and/or a ton of MFC/AFX headers. Generally on
Solaris you don't have such Kitchen Sink headers, so you won't get as
much benefit.

YMMV depending on disk (or network), CPU speed and the amount of header
dependency you have.

A bientot
Paul

-- 
Paul Floyd                 http://paulf.free.fr (for what it's worth)
Surgery: ennobled Gerald.


Relevant Pages

  • Re: Redirect COUT to file
    ... The old headers are non-standard, ... compile and link this file. ... execute the exe-file the program crashes and I get this error message: ... //BUT NOT WITH CYGWIN G++ ...
    (comp.lang.cpp)
  • Re: Automatically generate variables
    ... use any non-standard stuff in its own headers. ... I did *not* say the program was strictly conforming. ... See, it does compile. ... We are not discussing quality of microsoft implementation, ...
    (comp.lang.c)
  • Re: hid.dll & VC++ 6
    ... VC6 is too old. ... Many of the headers in the current WDK will not compile ... missing ')' before identifier 'HIDP_REPORT_TYPE' ...
    (microsoft.public.win32.programmer.kernel)
  • Re: resolving linker errors
    ... You can remove them from the solution, and the project would still compile. ... That means they are checked out of source control when you modify them, and the make process will monitro changes on the files and automatically recompile all dependend source files. ... If you do not add the headers, changes in these headers might not cause the moduels using the header to be recompiled. ... project likely uses lots of .h files that are not listed in the Solution Explorer - standard library headers, Windows headers, perhaps third-party libraries. ...
    (microsoft.public.vc.language)
  • Re: System headers, compiler conformance...
    ... When I compile it by invoking the compiler in conforming mode, ... Try using gcc -E to inspect the output of the pre-processor. ... See if the headers are there. ... don't use the c99 features in question. ...
    (comp.unix.programmer)