Improving IO Speed

monarch_dodra monarchdodra at gmail.com
Fri Mar 14 11:27:22 PDT 2014


On Friday, 14 March 2014 at 18:00:58 UTC, TJB wrote:
> Do you have any suggestions for improving the speed in this 
> situation?
>
> Thank you!
>
> TJB

I expect you'd get better performance with std.stdio rather than 
std.stream. stream is class based and (AFAIK) not as optimized 
for performance.

I'd make it look like this:

void main()
{
   auto input = File("T201212A.IDX"); //Not a class

   TaqIdx tmp;
   ...



 From there, I'd use either of `byChunk` or `rawRead`, I don't 
know which is most efficient.

   TaqIdx[] buf = (&tmp)[0 .. 1];
   while (input.rawRead().length)
   {
     ...
   }

   or
   ubyte[] buf = (cast(ubyte*)&tmp)[0 .. TaqIdx.sizeof];
   foreach ( b ; file.byChunks(buf) )
   {
     ...
   }

Give it a try and see if it runs faster.


More information about the Digitalmars-d-learn mailing list