[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-patch-tracker] [patch #7748] Improved speed for textscan & textr
From: |
Philip Nienhuis |
Subject: |
[Octave-patch-tracker] [patch #7748] Improved speed for textscan & textread for format repeat count |
Date: |
Tue, 20 Mar 2012 23:09:32 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 SeaMonkey/2.0.6 |
URL:
<http://savannah.gnu.org/patch/?7748>
Summary: Improved speed for textscan & textread for format
repeat count
Project: GNU Octave
Submitted by: philipnienhuis
Submitted on: Wed 21 Mar 2012 12:09:31 AM CET
Category: None
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
Inspired by this thread:
https://mailman.cae.wisc.edu/pipermail/help-octave/2012-March/050944.html
I have replaced some naive and extremely slow code in textread.m & textscan.m
and replaced it by block reading code. While there I also made some
improvement elsewhere.
Results on a Core Duo 2.5 GHz (WinXP):
octave-3.6.1.exe:1> dlmwrite ('test.csv', rand (16390, 4), ' ');
# Old textread:
octave-3.6.1.exe:2> tic; [a, b, c, d] = textread ('test.csv', "%f %f %f %f",
16384); toc
Elapsed time is 244.719 seconds.
octave-3.6.1.exe:3>
# New textread
octave-3.6.1.exe:1> tic; [a, b, c, d] = textread ('test.csv', "%f %f %f %f",
16384); toc
Elapsed time is 3.422 seconds.
octave-3.6.1.exe:2> test textread
PASSES 6 out of 6 tests
octave-3.6.1.exe:3>
# Old textscan:
octave-3.6.1.exe:1> fid = fopen ('test.csv');
octave-3.6.1.exe:2> tic; C = textscan (fid, "%f %f %f %f", 16384); toc
Elapsed time is 244.141 seconds.
octave-3.6.1.exe:3>
# New textscan:
octave-3.6.1.exe:1> fid = fopen ('test.csv');
octave-3.6.1.exe:2> tic; C = textscan (fid, "%f %f %f %f", 16384); toc
Elapsed time is 3.422 seconds.
octave-3.6.1.exe:3> test textscan
PASSES 13 out of 13 tests
octave-3.6.1.exe:4> fclose (fid);
# Just for comparison:
octave-3.6.1.exe:5> tic; C = dlmread ( 'test.csv', ' ', 'A1:D16384'); toc
Elapsed time is 0.2 seconds.
octave-3.6.1.exe:6> size (C)
ans =
16384 4
octave-3.6.1.exe:7>
.... so a binary textscan would still be preferrable.
Yet a 70+ times faster script version (for moderately sized files) isn't bad
either.
changeset attached, + the files themselves for those who can't wait nor
patch.
Enjoy
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Wed 21 Mar 2012 12:09:31 AM CET Name: textread_textscan.patch Size:
13kB By: philipnienhuis
<http://savannah.gnu.org/patch/download.php?file_id=25421>
-------------------------------------------------------
Date: Wed 21 Mar 2012 12:09:31 AM CET Name: textread.m Size: 6kB By:
philipnienhuis
<http://savannah.gnu.org/patch/download.php?file_id=25422>
-------------------------------------------------------
Date: Wed 21 Mar 2012 12:09:31 AM CET Name: textscan.m Size: 13kB By:
philipnienhuis
<http://savannah.gnu.org/patch/download.php?file_id=25423>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/patch/?7748>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-patch-tracker] [patch #7748] Improved speed for textscan & textread for format repeat count,
Philip Nienhuis <=