Invenietis/ck-core — pull request #13 by bcrosnier (2014-02-07 23:29:06+00:00)
Title: GrandOutput.Dispose()/BinaryFile performance fix

Currently, a BinaryFile's [FileStream](http://msdn.microsoft.com/en-us/library/d0y914c5%28v=vs.110%29.aspx) is created with 8 bytes of buffer.

With this, on my current machine, writing 30 000 entries took a whopping 82 minutes and 13 seconds.

Whoops.

During this time, the hard drive controller is hammered with writes, and obviously GrandOutput's disposal is halted while the BinaryFile isn't flushed away.

Increasing the buffer to FileStream's internal default of 4 KB (4096 bytes, according to Reflector/Decompiler) reduces this time to a mere 67 seconds; still a lot for a 4 MB output, granted, but better. 87 times better here, at least.

I did not notice any more improvement by increasing the buffer beyond 4 KB.

We can reduce this to 16 second if we blindly trust the OS' cache and drop FileOptions.WriteThrough, but I understand we want to keep it.