[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [octave] file i/o performance
From: |
Dmitri A. Sergatskov |
Subject: |
Re: [octave] file i/o performance |
Date: |
Wed, 25 May 2005 00:30:05 -0600 |
User-agent: |
Mozilla Thunderbird (X11/20050322) |
Mark Robinson wrote:
Rough estimates are that fgetl, strrep, strtok are 3x, 35x, 17x slower
in octave.
While I am not surprised that strrep and strtok are slower in Octave
than in Matlab, I was surprised that fgetl is so much slower
(since it is coded in C++, I expected it to be closer in speed to
matlab's version). So I did a simple test with my own data file
tic; for i = (1:100000) ; hl=fgetl(fid) ; end; toc
(each string is about 100 bytes long, in case it matters).
So for Matlab 6 I got 11 seconds, while with Octave 2.9.3 only 5.6 sec.
If I replace fgetl with fgets matlab gets 5.0 sec and Octave 5.4 sec as well.
I assume Matlab 7 had improved on fgetl (this difference by a factor of 2
looks ridiculous), but I would be surprised if they manage to speedup
fgets by factor of 3 as well...
So, I guess my question is (and again, it's *not* a complaint), for an
average guy like myself, is there any way I can improve upon this? Any
suggestions would be most welcome.
In a similar situation I write a parser program in C that outputs
text file in a format that octave can read with a command
hl = fgets(fid);
(hl -- is header with description of the data)
A = fscanf(fid, "%f %f %f ...", [n, inf]);
(so no loops involve and all my data end up in A).
Later I save A in oct-binary format, so subsequently
I read this saved data with load() command and that
is very fast.
Some time ago I was trying to figure out how to write a simple oct-binary
file (which contains a matrix and a string) but did not succeed
(I did not try very hard though).
Thank you.
Mark
Dmitri.
--
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------