Craig,
I have to disagree with some of your definitions as I use the terms -- I do not
know how they are defined in the standard, except that they are allowed not to
be defined :-)
> The best standard procedure for this purpose is the Fortran **95**
>subroutine
>CPU_TIME. It takes a single real argument, which is the elapsed processor time
>in
>seconds. The exact definition of the processor time is left imprecise. If you
>want to time a procedure, you need to call CPU_TIME twice, with two separate
>actual
>arguments.
(My mail has re-formatted, I've just added a chevron to each line.)
The terms "elapsed" and "processor" time to me are different. Elapsed is
wall-clock, and includes all the overheads that a user experiences. Processor
time is (if returned by the OS) a measure of the CPU and is what I use for
comparing timing of algorithms. The former is irrelevant for determining CPU
intensive algorithms; it is also biased by how many users are active on the
system.
> Other alternatives include the F90 SYSTEM_CLOCK subroutine and the
>DATE_AND_TIME subroutine. If you want to time sections of code, you will again
>need to call either of these subroutines twice, with separate sets of arguments
>for
>the beginning and the end.
These all give (what I term) elapsed time. Not a true analysis of the merits of
different algorithms -- unless on a single user system with no other processes
running.
> There is no standard way in F9x to start a timer at one point and then read
>that timer later on. You will need to create your own timer using one of the
>subroutines I mentioned above.
I dunno :-) :-)
:-) Assuming CPU_TIME returns meaningful results (else use elapsed time), I
would have thought the following code is standard -- but not a one-liner:
CALL CPU_TIME(T1)
CALL ROUTINE_TO_MEASURE
CALL CPU_TIME(T2)
WRITE(*,*) 'Time taken ' , T2-T1
:-)
Hmmm, I'm not a UNIX person ( -- VMS), does the time command measure CPU time or
wall-clock time? If the latter, it is **not** a good measurement of relative
algorithms on a multi-user system. Using elapsed time, I can see situations
where bubblesort could beat quicksort. {On a multi-user system heavily loaded,
a batch process running quicksort on a low priority could take longer wall-clock
than an interactive bubblesort on a higher prority -- I frequently see similar
situations on my production machine.]
>varadharajan wrote:
>
>> Hello!
>> I wanted to know if there is some F90 command to time subroutines and
>> functions withing programs. Whole programs can be timed by the time
>> command in unix but what about subroutines within? Is there such a
>> facility?
>>
>> Regards,
>> Varadharajan S
Regards, Paddy
Paddy O'Brien,
Transmission Development,
TransGrid,
PO Box A1000, Sydney South,
NSW 2000, Australia
Tel: +61 2 9284-3063
Fax: +61 2 9284-3050
Email: [log in to unmask]
Either "\'" or "\s" (to escape the apostrophe) seems to work for most people,
but that little whizz-bang apostrophe gives me little spam.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|