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

Home » Public Forums » archive » READS as a speed improvement or simply style?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
READS as a speed improvement or simply style? [message #52445] Thu, 08 February 2007 13:19 Go to previous message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
This should be simple for folks out there. Is reads fast as I suspect
it is as compared to other ways?

; start with a date yyyydddhhmmss format
euv_date2 = '2000111223344'
; I want to split it into an array
; this can be done this way:
year = strmid(trim(euv_date2), 0, 4)
doy = strmid(trim(euv_date2), 4, 3)
hour = strmid(trim(euv_date2), 7, 2)
minute = strmid(trim(euv_date2), 9, 2)
second = strmid(trim(euv_date2), 11, 2)
time_arr = [year, doy, hour, minute, second]

; or this way
time_arr = strarr(5)
reads, euv_date2, time_arr, format='(a4,a3,a2,a2,a2)'

I tested he speed with this code:
timer, 0, /start
FOR i=0l, 1e6 DO BEGIN
euv_date2 = '2000111223344'
; I want to split it into an array
; this can be done this way:
year = strmid(trim(euv_date2), 0, 4)
doy = strmid(trim(euv_date2), 4, 3)
hour = strmid(trim(euv_date2), 7, 2)
minute = strmid(trim(euv_date2), 9, 2)
second = strmid(trim(euv_date2), 11, 2)
time_arr = [year, doy, hour, minute, second]
ENDFOR
timer, 0, /stop, /print
timer, 1, /start
FOR i=0l, 1e6 DO BEGIN
time_arr = strarr(5)
reads, euv_date2, time_arr, format='(a4,a3,a2,a2,a2)'
ENDFOR
timer, 1, /stop, /print
END

to this result:
IDL> .run test
% Compiled module: $MAIN$.
Timer 0 started: 2007 Feb 8 14:16:59 Thu
Timer 0 stopped: 2007 Feb 8 14:17:29 Thu
Elapsed time: 00:00:29 (29.851995 sec)
Timer 0 started: 2007 Feb 8 14:17:29 Thu
Timer 0 stopped: 2007 Feb 8 14:17:37 Thu
Elapsed time: 00:00:08 (8.1684880 sec)

Which is pretty amazing!!!


anyone have any evidence real or experiential on how much faster reads
is for other examples?



Brian

------------------------------------------------------------ ---------
Brian A. Larsen
Dept. of Physics
Space Science and Engineering Lab (SSEL)
Montana State University - Bozeman
Bozeman, MT 59717
[Message index]
 
Read Message
Read Message
Previous Topic: A function for use with psym
Next Topic: eps from xvolume

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

Current Time: Fri Oct 10 14:22:30 PDT 2025

Total time taken to generate the page: 1.43901 seconds