Why GNU coreutils/dd is creating a dummy file more efficiently than D's For loop?
Daniel Kozak
kozzi11 at gmail.com
Thu May 23 21:35:53 UTC 2019
On Thu, May 23, 2019 at 11:19 PM Daniel Kozak <kozzi11 at gmail.com> wrote:
Fixed version without decode to dchar
void main()
{
import std.range : array, cycle, take;
import std.stdio;
import std.utf;
immutable buf_size = 8192;
immutable buf = "\x00".byCodeUnit.cycle.take(buf_size).array;
auto cnt = 50_000_000 / buf_size;
immutable tail = "\x00".byCodeUnit.cycle.take(50_000_000 %
buf_size).array;
File file = File("test.txt", "w");
while(cnt--)
file.rawWrite(buf);
file.rawWrite(tail);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20190523/be759948/attachment.html>
More information about the Digitalmars-d-learn
mailing list