read() performance - Linux.too?

Bob W nospam at aol.com
Mon Jul 24 14:41:30 PDT 2006


"Dave" <Dave_member at pathlink.com> wrote in message 
news:ea1g68$nhl$1 at digitaldaemon.com...
>
> It's more than likely the GC, the same happens w/ a program like this:
>
> import std.outbuffer;
> import std.string : atoi;
> import std.stdio  : wrl = writefln;
>
> void main(char[][] args)
> {
>     int n = args.length > 1 ? atoi(args[1]) : 10_000_000;
>     OutBuffer b = new OutBuffer;
>     for(int i = 0; i < n; i++)
>     {
>         b.write("hello\n");
>     }
>     wrl(b.toString.length);
> }
>
> Run w/o an argument (n = 10_000_000), on Windows it takes forever (starts 
> swapping), on Linux it takes about a second.


Thanks for your info - I'll remember it as a warning.

But this is probably a different case. Your program is
dynamically resizing b's buffer. This requires more
overhead than just releasing a piece of memory which
was allocated in one single step.






More information about the Digitalmars-d mailing list