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

Home » Public Forums » archive » 'timer' routine enclosed
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
'timer' routine enclosed [message #17293] Thu, 30 September 1999 00:00
David L. Keller is currently offline  David L. Keller
Messages: 4
Registered: September 1999
Junior Member
I'll bet this has been done before (I seem to recall a
'Yorick' routine that may
have inspired this one). But I couldn't find it, so I wrote
it and now I'm sharing.
Profuse on-line help should explain how to run it. Code is
short, the help and
doc are long.

-- Dave --


pro timer,ti,lbl,new=new

nmandparm = 2
IF n_params(0) lt nmandparm THEN BEGIN
QHELP:
print," "
print,"Key in:"
print," timer,ti,lbl
print,"Where:"
print," Example:"
print," timer,ti,'Start'
print," mysubroutine,fake,args
print," timer,ti,'Mysubroutine'
print," c = a + b
print," timer,ti,'Add'
print," ;long section of code
print," timer,ti,'Long section'"
print," "
print,"And then to view the timings you might wish to
use:"
print," ptimer,ti"
print," Mysubroutine 9.7179999"
print," Add 2.4690001"
print," Long section 2.0500000"
print," "
print,"To 'start over'"
print," timer,ti,'new project',/new
return
ENDIF

;DOESN'T EXIST YET? START OVER?
IF (nel(ti) eq 0) OR keyword_set(new) THEN BEGIN
dubble = systime(1)
ti = {timertype,time:0.0D,label:string(lbl)}
ti.time = dubble
ENDIF ELSE BEGIN
;APPEND NEW ONE
q=ti(0) & q.time=systime(1) & q.label=string(lbl)
ti = [ti,q]
ENDELSE
END


pro ptimer,ti

nmandparm = 1
IF n_params(0) lt nmandparm THEN BEGIN
QHELP:
print," "
print,"Key in:"
print," ptimer,ti
print,"Where:"
print," ti is a structure from 'timer'"
print," "
print,"Where:"
print," Example:"
print," timer,ti,'Start'
print," mysubroutine,fake,args
print," timer,ti,'Mysubroutine'
print," c = a + b
print," timer,ti,'Add'
print," ;long section of code
print," timer,ti,'Long section'"
print," "
print,"And then to view the timings you might wish to
use:"
print," ptimer,ti"
print," Mysubroutine 9.7179999"
print," Add 2.4690001"
print," Long section 2.0500000"
print," "
print,"To 'start over'"
print," timer,ti,'new project',/new
return
ENDIF


;print times from 'timer' routine
;'ti' is the 'timer' structure
vals = ti.time
diff = shift(vals,-1)-vals
FOR i=1,n_elements(vals)-1 DO BEGIN
print,ti(i).label,diff(i-1)
ENDFOR
END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Using Callable IDL with added system routines from C++ (or C)
Next Topic: Re: Using Callable IDL with added system routines from C++ (or C)

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

Current Time: Wed Oct 15 15:59:35 PDT 2025

Total time taken to generate the page: 0.64415 seconds