I'm surprised this costs so much time.
How did you test all this? Did you use a HDD, SDD or ram disk? I would expect that the heavy I/O for loading the documents from disk would cause most of the delay.
I just measured loading time, because of repeating tests, all data were taken from RAM cache. Loading documents doesn't produce heavy I/O - average C source is 30 Kb.
-- Best regards, Pavel Roschin aka RPG