Entering content frameRuntime Measurement of Database Accesses Locate the document in its SAP Library structure

The following example shows how you can use the GET RUN TIME FIELD statement to measure the runtime of database accesses.

Example

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.

TABLES SBOOK.

T = 0.
DO N TIMES.
  GET RUN TIME FIELD T1.

* Offset

  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.
  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-CARRID, SBOOK-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'.

The output might look as follows:

Mean Offset Runtime :                25,22 microseconds

Mean Runtime SELECT * :           257.496,85 microseconds

Mean Runtime SELECT List:           167,904.63 microseconds

This example analyses the runtime of three program segments:

· an ‘empty’ program segment to determine the offset of the runtime measurement

· a program segment that reads all data from 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 ignored in this case and that reading specific columns of a table is faster than reading complete rows.

 

 

 

 

 

 

 

Leaving content frame