On Thursday, 23 May 2019 at 18:37:17 UTC, H. S. Teoh wrote:
On Thu, May 23, 2019 at 06:20:23PM +0000, kdevel via Digitalmars-d-learn wrote:
On Thursday, 23 May 2019 at 09:44:15 UTC, Cym13 wrote:
[...]
> To go fast, read/write bigger chunks.

Or use rawWrite instead of write (reduces the runtime to about 1.6 s). When using write time is IMHO spent in unicode processing and/or locking. Or write more characters at a time. The code below takes 60 ms to complete.

If you're on Linux, writing a bunch of zeroes just to create a large file is a waste of time. Just use the kernel's sparse file feature:

        https://www.systutorials.com/136652/handling-sparse-files-on-linux/

The blocks won't actually get allocated until you write something to them, so this beats any write-based method of creating a file filled with zeroes -- probably by several orders of magnitude. :-P


T

Yes using sparse files is good, but only for this case. If you need write something else than null it is not so usable. But AFAIK not all FS support this anyway

Reply via email to