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:06:25 UTC 2019
On Thu, May 23, 2019 at 11:10 AM BoQsc via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:
> This code of D creates a dummy 47,6 MB text file filled with Nul
> characters in about 9 seconds
>
> import std.stdio, std.process;
>
> void main() {
>
> writeln("Creating a dummy file");
> File file = File("test.txt", "w");
>
> for (int i = 0; i < 50000000; i++)
> {
> file.write("\x00");
> }
> file.close();
>
> }
>
>
> While GNU coreutils dd can create 500mb dummy Nul file in a
> second.
> https://github.com/coreutils/coreutils/blob/master/src/dd.c
>
> What are the explanations for this?
>
https://matthias-endler.de/2017/yes/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20190523/0307c8ab/attachment.html>
More information about the Digitalmars-d-learn
mailing list