[erlang-questions] Managing a huge binary file

Salvador Tamarit stamarit@REDACTED
Tue Apr 30 14:08:55 CEST 2013


2013/4/30 Magnus Henoch <magnus@REDACTED>:
> Salvador Tamarit <stamarit@REDACTED> writes:
>
>> I have been trying to solve this problem with different solutions, but
>> I always get stucked in reading the file. I'm reading it sequentally.
>> I open the file with:
>>
>> file:open(FileName,[binary])
>>
>> then I read each number with:
>>
>> file:read(FDevice, 4)
>>
>> this works fine, but too slow.
>
> Try opening the file with:
>
> file:open(FileName,[binary, raw, read_ahead])
>
> I just wrote a little escript that reads four bytes at a time, and
> adding 'raw' and 'read_ahead' seems to make it twice as fast (1.5 s vs 3
> s for a 2 MB file).  Interestingly, read_ahead alone didn't make a
> difference, and raw alone actually made it slower.

Twice fast only changing these options... :o

Unfortunately, It still take a lot of time to read the file :P

>
> Regards,
> Magnus
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list