|
|
Re: Number of line in a text file
Posted:
Nov 3, 2006 2:57 AM
|
|
Thanks a lot for your explanations. Benoît.
Kirill wrote: > > > Indeed -- 4.65sec vs former 7.6sec!!! > > JWagberg wrote: >> Kirill wrote: >> > while ~feof(fh) >> > ch = fread(fh, chunksize, 'uchar'); >> > if isempty(ch) >> > break >> > end >> ... >> > n2 = n2 + sum(ch == char(10)); >> >> >> Prepend the 'uchar' with an asterisk, '*uchar', and you can read > eight >> times as much with each chunk and the (ch == char(10)) will also > speed >> up by a factor five. >> >> /jewa > >
|
|