ABAP Keyword Documentation → ABAP − Reference → program editing → Testing and Checking Programs → Runtime Measurements
GET RUN TIME
Other versions: 7.31 | 7.40 | 7.54
Syntax
GET RUN TIME FIELD rtime.
Effect
When GET RUN TIME
is executed for the first time after an
internal session is
created, the value 0 is passed to the variable rtime
. After each further
execution in the same internal session, the program runtime that has elapsed since the first execution,
in microseconds, is passed to the variable rtime
. The return value of the
statement is of the data type i
. The following can be specified for rtime
:
-
An existing variable of the data type
i
or a variable to which the typei
can be converted. -
An inline declaration
DATA(var)
, where a variable of typei
is declared.
Notes
-
To measure the runtime of program sections, a
GET RUN TIME
statement can be executed before and after the required section and then the difference of the results can be calculated. The sequence of statements set within limits is called the measuring section, and the duration calculated for it is called the measuring interval. -
The statement
GET RUN TIME
does not accumulate the time taken to execute individual ABAP statements. Instead it defines actual points in time with respect to the processor time. In particular, when there are differences between these points in time, the statement respects the time taken for an internal session to be rolled out of the memory In a conceptual sense, a time defined usingGET RUN TIME
can be viewed as a time stamp. Unlike real POSIX time stamps, a time defined usingGET RUN TIME
is always precise to the microsecond (regardless of the platform), while also being restricted to the value range of the data typei
. -
The maximum resolution of the command
GET RUN TIME
is a microsecond. Shorter measuring intervals cannot be determined reliably. - The value range of the return value of the statement must be respected. Do not create measuring sections that are too large (not greater than 1000 s) and also do not create any measuring sections using accesses to external data or using screen calls and so on.
-
The statement SET RUN
TIME CLOCK RESOLUTION can be used to defined the measuring precision before the first execution of
GET RUN TIME
, which is used to determine the runtime. - The class CL_ABAP_RUNTIME provides methods for creating objects whose method GET_RUNTIME can be used to execute multiple runtime measurements with different resolutions in an internal session (see also class for runtime measurements).
-
The runtime of program sections can also be determined using the tool runtime analysis.
Example
Determines the calculation time for calculating the tangent of 1. Since the runtime of the statement
is less than a microsecond, the runtime of multiple executions in an inner loop is measured. The execution
time for the loop itself is also measured to deduct it as an offset. These measurements are executed
more than once in an outer loop and the mean value is calculated using division by n0
. Division by ni
determines the runtime of an individual statement.
DATA: t0 TYPE i,
no TYPE i VALUE 100,
ni TYPE i VALUE 1000.
DO no TIMES.
GET RUN TIME FIELD DATA(t1).
DO ni TIMES.
DATA(res) = tan( 1 ).
ENDDO.
GET RUN TIME FIELD DATA(t2).
GET RUN TIME FIELD DATA(t3).
DO ni TIMES.
ENDDO.
GET RUN TIME FIELD DATA(t4).
t0 += ( t2 - t1 ) - ( t4 - t3 ).
ENDDO.
DATA(tm) = CONV decfloat34( t0 / ni / no ).