Skip to content

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

Runtime Measurement of Database Accesses

The example demonstrates how to use the GET RUN TIME FIELD statement at runtime.

Other versions: 7.31 | 7.40 | 7.54

Source Code

REPORT demo_special_tech_get_runt_db.

DATA: t1 TYPE i,
      t2 TYPE i,
      t  TYPE p DECIMALS 2.

PARAMETERS n TYPE i DEFAULT 10.

DATA: toff  TYPE p DECIMALS 2,
      tsel1 TYPE p DECIMALS 2,
      tsel2 TYPE p DECIMALS 2.

DATA sbook_wa TYPE sbook.

t = 0.
DO n TIMES.
  GET RUN TIME FIELD t1.

<span class="blue">* Offset</span>

  GET RUN TIME FIELD t2.
  t2 = t2 - t1.
  t = t + t2 / n.
ENDDO.
toff = t.
WRITE: / 'Mean Offset Runtime     :', toff, 'microseconds'.

SKIP.
t = 0.
DO n TIMES.
  GET RUN TIME FIELD t1.

  SELECT *
         FROM sbook
         INTO sbook_wa.
  ENDSELECT.

  GET RUN TIME FIELD t2.
  t2 = t2 - t1.
  t = t + t2 / n.
ENDDO.
tsel1 = t - toff.
WRITE: / 'Mean Runtime SELECT *   :',
         tsel1, 'microseconds'.

SKIP.
t = 0.
DO n TIMES.
  GET RUN TIME FIELD t1.

  SELECT carrid connid
         FROM sbook
         INTO (sbook_wa-carrid, sbook_wa-connid).
  ENDSELECT.

  GET RUN TIME FIELD t2.
  t2 = t2 - t1.
  t = t + t2 / n.
ENDDO.
tsel2 = t - toff.
WRITE: / 'Mean Runtime SELECT List:',
          tsel2, 'microseconds'.

Description

In this example, the runtime of three program segments is investigated:

  • An empty program segment for determining the offset of the runtime measurement
  • A program segment that reads all data of database table SBOOK
  • A program segment that reads two columns of database table SBOOK

The result shows that the offset of the runtime measurement can be neglected in this case and that reading particular columns of a table is faster than reading entire rows.