Faster ways to redirect stdout of child process to file
Thomas Mader via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 11 15:09:03 PDT 2014
I use
auto pipes = pipeProcess( cmd, Redirect.stdout |
Redirect.stderr );
to redirect stdout of the newly created subprocess via pipes to a
file. The redirect itself happens in a newly created thread
(because I need to wait for the subprocess to finish to take the
exact elapsed time) doing basically:
pipes.stdout.byChunk( 1024 * 1024 ).copy(
cof.lockingTextWriter() );
This happens to use much of my CPU time (~25%). I wonder if there
is no faster way to do this.
I use this method because I want to be platform independent.
Thomas
More information about the Digitalmars-d-learn
mailing list