Speeding up text file parser (BLAST tabular format)

Fredrik Boulund via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 15 01:53:35 PDT 2015


On Monday, 14 September 2015 at 18:08:31 UTC, John Colvin wrote:
> On Monday, 14 September 2015 at 17:51:43 UTC, CraigDillabaugh 
> wrote:
>> On Monday, 14 September 2015 at 12:30:21 UTC, Fredrik Boulund 
>> wrote:
>>> [...]
>>
>> I am going to go off the beaten path here.  If you really want 
>> speed
>> for a file like this one way of getting that is to read the 
>> file
>> in as a single large binary array of ubytes (or in blocks if 
>> its too big)
>> and parse the lines yourself. Should be fairly easy with D's 
>> array slicing.
>
> my favourite for streaming a file:
> enum chunkSize = 4096;
> File(fileName).byChunk(chunkSize).map!"cast(char[])a".joiner()

Is this an efficient way of reading this type of file? What 
should one keep in mind when choosing chunkSize?


More information about the Digitalmars-d-learn mailing list