comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » How to fasten formatted printf?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
How to fasten formatted printf? [message #92524] Mon, 04 January 2016 18:01 Go to previous message
enod is currently offline  enod
Messages: 41
Registered: November 2004
Member
Hi all,

I usually have over a thousand text files to write. Each file contains 9 columns and several thousand lines. The below is a test.

PRO TEST_PRINTF_FORMATTED_LARGE
ofile='c:\test.txt'
data=DBLARR(9,7000)

t0=SYSTIME(/seconds)
OPENW,fid,ofile,/get_lun
PRINTF,fid,data,format='((3(1x,f10.5),1x,3(1x,f8.2),1x,3(1X, f4.1)))'
FREE_LUN,fid
DELTA_T=SYSTIME(1)-T0*1d0
PRINT,'Total time: '+STRING(DELTA_T,FORMAT='(f)')+' seconds'
END

On my notebook, it takes about 0.14 seconds to finish the above task, e.g.

% Compiled module: TEST_PRINTF_FORMATTED_LARGE.
Total time: 0.1449999809265137 seconds
% Compiled module: TEST_PRINTF_FORMATTED_LARGE.
Total time: 0.1349999904632568 seconds
% Compiled module: TEST_PRINTF_FORMATTED_LARGE.
Total time: 0.1500000953674316 seconds

For 1000 files, it will take over 2 minutes. I wonder whether there is a way to do it very quickly.

Thank you very much!

Yunfeng Tian
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: GDL 0.9.6 delivered
Next Topic: Matrix operations with IDL: Avoiding for loops

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 14:11:44 PDT 2025

Total time taken to generate the page: 0.00184 seconds