From: us on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hoj554$jjq$1(a)fred.mathworks.com>...
> Dear Matt J!
>
> > > C = dataread('string', path, '%s', 'delimiter', pathsep);
>
> > Interesting about dataread(), though. It's not documented...
>
> You can call the documented STRREAD. But this adds a buffer size to the call of the MEX DATAREAD only and wastes a remarkable chunk of time with using VARARGIN/VARGARGOUT.

well... let us see...

s=repmat('1,',1,1000000);
tic;
for i=1:100
r1=dataread('string',s,'%d','delimiter',',');
end
t1=toc;
tic;
for i=1:100
r2=strread(s,'%d','delimiter',',');
end
t2=toc;
disp([t1;t2]);
%{
% wintel sys: ic2/2*2.6ghz/2gb/winxp.sp3.32/r2010a
26.095 % <- dataread
26.252 % <- strread
%}

not ...very much... of a difference...

us
From: Jan Simon on
Dear us!

> s=repmat('1,',1,1000000);
> % wintel sys: ic2/2*2.6ghz/2gb/winxp.sp3.32/r2010a
> 26.095 % <- dataread
> 26.252 % <- strread

Not a very realistic problem.
What about this:

P = sprintf('%f ', rand(1, 20));
S = ' ';
tic;
for i = 1:5000
v = strread(P, '%s', 'delimiter', P);
end
toc;

tic;
for i = 1:5000
v = dataread('string', P, '%s', 'delimiter', P);
end
toc;

==> Windows XP, 1.5GHz P-M, 2009a:
DATAREAD: 0.33 sec
STRREAD: 0.45 sec
27% faster - without tricks.

You can always minimize the effects of the calling overhead by simply using large problems. But for small problems, e.g. if you split an absolute path at the file separators, the overhead of STRREAD is dispensable waste of time.

Of course I do this with the usual MEX Str2Cell, which omits the parsing of the inputs directly ==> 0.11 sec. But it has a certain advantage to use Matlab's toolbox functions for discussions in the newsgroup.

Then test DATAREAD with the file inout:
F = which('plot.m');
tic;
for i = 1:1000
v = dataread('file', F, '%s', 'delimiter', '\n');
end
toc;

tic;
for i = 1:1000
v = textread('F, '%s', 'delimiter', '\n');
end
toc;

==>
DATAREAD: 0.88 sec
TEXTREAD: 2.91 sec
70% of the time is wasted for checking the type and existence of F !!!

Of course you can call TEXTREAD for a 2.1 GigaByte file also and the overhead will by much smaller ;-)

Kind regards, Jan
From: forkandwait w on
> > Is there a way to generate a list of all functions defined recursively
> > under a path, such that you can loop over that list? I think this is two
> > questions -- how to loop over cell arrays of strings, and how to get a
> > list of all defined funcs.
>
> I can think of a few scenarios where you could want to do that, but in many
> of those scenarios I can also think of ways to do the task in that scenario
> more efficiently. What are you trying to do with this list?

I want to test all of the functions by feeding their names into a test harness one after the other. I also sort of just want to know how it would work. Using "what" with a split of the path seems like the best approach.
First  |  Prev  | 
Pages: 1 2 3
Prev: mean block in simulink
Next: Newbie Newey-West