file rawRead and rawWrite in chunks example

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 9 03:40:04 PDT 2015


On Sunday, 9 August 2015 at 00:50:16 UTC, Ali Çehreli wrote:
> Ali

Now benchmarks write and read separately:

https://github.com/nordlow/justd/blob/0d746b2c1800a82a61a6cb7edcabfd9664066b2c/tests/t_rawio.d

Couldn't the chunk logic be deduced aswell? Something like:

void rawWriteInAutoChunks(R)(File f, R r)
{
     const count = preferred_disk_write_size / 
sizeof(ElementType!R);
     return r.chunks(count).each!(a => f.rawWrite(a.array));
}

What would a suitable value for `preferred_disk_write_size` be?


More information about the Digitalmars-d-learn mailing list