On Thu, 21 Jun 2012 14:56:37 +0100, Paul <phshaf...@gmail.com> wrote:
I wrote a program that parses a text file and writes results as it is
processing the file (i.e. many writeln()'s). On my local harddrive it
works fine. When I later used it on a file located on a file server, it
went from 500ms to 1 minute processing time.
It there a more efficient way to write out the results that would say
maybe only access the harddrive as it closes the connection...or
somesuch?
Thanks for your assistance.
I imagine writeln is synchronous/non-overlapped IO. Meaning, the call to
writeln doesn't return until the write has "completed". So, on every call
you're basically waiting for the network IO to complete before you process
something else locally.
What you want is asynchronous or overlapped IO where the write starts, and
the function returns, and then you later get notified that the write has
completed. This lets you continue processing locally while the write
happens in the background.
That's the theory, in practice I'm not sure what options you have in
phobos for overlapped IO. If you're on windows you can pull in the win32
functions CreateFile, WriteFile etc and define the data structures
required for overlapped IO.
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/