I thought of that, so I tested it on a real machine and got same relative results. And I did run every compilation 5-7 times to make sure the files were well cached.

Anyway, the conclusion is that it doesn’t matter. If the difference for 10000 almost empty files is a second or two more, then your real world project won’t care whatsoever which include method you use.

on 27 Jun 2014 at 18:33:18 3.John Doe said …

Two things:

1. If you tested on an actual machine, why not edit the post with those times instead?

2. In the Windows you’re running, what else are you running? Anti-virus, hooks, explorer extensions, etc? Can you feasibly run in a fresh W7 with a fresh VC++2010?

on 27 Jun 2014 at 21:42:17 4.Foster Brereton said …

The question I am interested in getting answered is why is MSVC almost 10x slower in the #ifndef case than clang, and what can be done to mitigate that cost?

Since I got the same relative results, it won’t matter if I put those numbers in. They’ll have the same factors to the other numbers.

It doesn’t matter what the Windows machine was running, as I redid the tests several times and got the same numbers. Also, since the VBox was running on the Windows machine, any host slowdown would also affect the guests – especially I/O slowdowns. Since there is no seen I/O slowdown, and since tests are run multiple times to cache files, one can conclude that raw I/O throughput is not the issue. But, no active AV.

And again, test is for 3x 10000 files. For a single file, MSVC’s slowest case would thus be somewhere between 0.0005153 and 0.0001718 seconds – also known as 0.5 and 0.2 milliseconds.

There is no cost to mitigate. The conclusion is that include speed is super fast in ALL compilers.