I want to generate a test scene for a unit-test (big file parser). What will be faster, to have a test file and to perform I/O on it, or to generate a large memory buffer using some static parameters during the compilation?
If the generation code needs a lot of CPU cycles, using a file as a cache might bring performance benefits. If not, using a file as an intermediate storage can slow things down. The only sensible way to find out is try both and measure. The answer will also depend on your hardware & environment.
However, if you have two possible solutions at hand, start with the one which is easier to implement and check if it is quick enough for your purposes. If that is the case, there will probably no need to implement an even faster way.
Normally, I would expect the simpler solution to be a cache-free one. If that is true, I recommend to go that way, even if the other solution might be faster. Note when you introduce a file cache, you need to make sure you don't forget to update your file whenever the static parameter or the generation code changes, which means additional administrative overhead.
However, if you already have a lot of test data in form of files at hand, and don't need to write a generator for this data, then better try this solution first and check if it is fast enoough.