Re: precompiled headers and Sun Studio 10...

From: Thomas Maier-Komor (maierkom_at_lpr.e-technik.no-spam.tu-muenchen.de)
Date: 09/22/05


Date: Thu, 22 Sep 2005 09:43:47 +0200

Trond Norbye schrieb:
> 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 used the following make rule to compile the files:
>
> $(COMPILE.cc) -xpch=use:pch -xpchstop=pch.h filename
>
> And when I timed the runs I got:
>
> without precompiled headers: 30 seconds, with precompiled headers: 1m 30
> sec.
>
> When I look at the content of pch.Cpch it looks to me that this file is
> just a preprocessed version of all of the headers. Is this correct?
>
> Should I be doing this another way?
>
> Trond

in my experience using precompiled headers is not worth the effort.
There might be cases where you really get improved compile time.
But I guess these situations are limited to case of e.g. gui
development, where most translation units include the same set
of header files. In my project it also gave a regression
concerning compile-time and additional dependencies for
the build process. So I switched back to normal compilation.
But then this was just a small project and I was using Studio 9.

Cheers,
Tom



Relevant Pages

  • Re: precompiled headers and Sun Studio 10...
    ... Instead of a reduced compile time, ... took me longer to optimize finding which headers gave me that gain than ... YMMV depending on disk, CPU speed and the amount of header ...
    (comp.unix.solaris)
  • 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)