GET RUN TIME
GET RUN TIME FIELD rtime.
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
An existing variable of the data type
ior a variable to which the type
ican be converted.
An inline declaration
DATA(var), where a variable of type
To measure the runtime of program sections, a
GET RUN TIMEstatement 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.
GET RUN TIMEdoes 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 using
GET RUN TIMEcan be viewed as a time stamp. Unlike real POSIX time stamps, a time defined using
GET RUN TIMEis always precise to the microsecond (regardless of the platform), while also being restricted to the value range of the data type
The maximum resolution of the command
GET RUN TIMEis 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.
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 = t0 + ( ( t2 - t1 ) - ( t4 - t3 ) ). ENDDO. DATA(tm) = CONV decfloat34( t0 / ni / no ).