Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  program editing →  Testing and Checking Programs →  Runtime Measurement 

GET RUN TIME

Short Reference

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 seconds, is passed to the variable rtime. The return value of the statement is of the data type i.


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 conceptional sense, a time defined using GET RUN TIME can be viewed as a time stamp. Unlike real POSIX time stamps, a time defined using GET RUN TIME is always precise to the microsecond (regardless of the platform), while also being restricted to the value range of the data type i.
  • The maximum resolution of the command GET RUN TIME is a microsecond. Shorter meaasuring 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 precisiion before the first execution of GET RUN TIME, which is used to determine the runtime.
  • The class CL_ABAP_RUNTIME provides methods for generating 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 exection time for the loop itself is also measured in order 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, 
      t1    TYPE i, 
      t2    TYPE i, 
      t3    TYPE i, 
      t4    TYPE i, 
      tm    TYPE f, 
      no    TYPE i VALUE 100, 
      ni    TYPE i VALUE 1000, 
      res   TYPE f. 

DO no TIMES. 
  GET RUN TIME FIELD t1. 
  DO ni TIMES. 
    res = TAN( 1 ). 
  ENDDO. 
  GET RUN TIME FIELD t2. 
  GET RUN TIME FIELD t3. 
  DO ni TIMES. 
  ENDDO. 
  GET RUN TIME FIELD t4. 
  t0 = t0 + ( ( t2 - t1 ) - ( t4 - t3 ) ). 
ENDDO. 

tm = t0 / ni / no.

Continue

Runtime Measurement of Database Accesses