[erlang-questions] Managing a huge binary file
Tue Apr 30 13:56:38 CEST 2013
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:
> 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.
More information about the erlang-questions