octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

accelerating sscanf ?


From: CdeMills
Subject: accelerating sscanf ?
Date: Thu, 22 Mar 2012 08:28:05 -0700 (PDT)

Hello,
when reading big files with my dataframe package, most of the time is spent
in converting string to double. The steps are:
1) the whole file is cut into lines
2) each line is then split using the field separator and stored in a cell
array
3) the conversion is performed as
 the_line = cellfun (@(x) sscanf (x, "%f", locales), dummy, 'UniformOutput',
false);

This is to say that sscanf is called for each field. During the call, a
stream is created, new locales are set, and so on. Some functions working on
strings accept cells of strings as input. Would it be OK to have sscanf also
accept cell array as first member ? The algorithm will then be:
1) create a istringstream, put the right locale on it. Create a cell array
for the output result.
2) for each entry in args(0)
   - verify that it's a string
   - put its value into the istringstream
   - scan it, and store  the result in the output cell array

The issue I have is that files with 7500 lines of 12 fields take more than
120 seconds to be parsed. If the number of calls is reduced by a factor of
10 at the interpreter level, the speedup would be worth a try ? What do you
think about it ?

Pascal 


--
View this message in context: 
http://octave.1599824.n4.nabble.com/accelerating-sscanf-tp4495842p4495842.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]