octave-maintainers
[Top][All Lists]
Advanced

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

Re: accelerating sscanf ?


From: CdeMills
Subject: Re: accelerating sscanf ?
Date: Thu, 22 Mar 2012 10:41:13 -0700 (PDT)

Daniel Sebald wrote
> 
> 
> Pascal,
> 
> What you describe sounds very similar to the issue that we've been 
> discussing concerning bin2dec, i.e., better performance when working 
> with strings inside cells.  7500 lines with 12 fields is what I would 
> consider "database" application.  Once the data is in the cells, Octave 
> can do a lot of powerful things to analyze that data.  However, it 
> appears getting large data sets or transforming them is somewhat 
> inefficient.
> 
> In any case, I'd like to point you to an alternative you might try. 
> There is a string function called strsplit which can be pretty nice. 
> Here's an example:
> 
> charstr = "these, are, fields\nseparated, by, commas";
> lines = strsplit(charstr, "\n")
> for i=1:length(lines)
>    C(i,:) = strsplit(lines{i}, ',');
> end
> C
> 
> If one brings in the whole file as a hunk of characters then uses 
> strsplit, that can be efficient.  The only problem--I don't know the 
> format of your data--is having text strings which have the delimiter 
> character inside.
> 
> Dan
> 
Hello Daniel,

thanks for your reply. I did a quick-and-dirty profiling. I already used
strplit inside a cellfun to cut lines into fields, and this amounts for
around one second. The repeated calls to sscanf amount to 120 seconds, this
is THE part which requires speedup.

In between, I took inspiration from strfind, and implemented something
similar. Compilation is ongoing...

Regards

Pascal

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


reply via email to

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