SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Speed up a program by pausing all the other workprocesses



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Performance tuning | Производительность
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Nov 17, 2007 10:20 pm    Post subject: Speed up a program by pausing all the other workprocesses Reply with quote

Code:
 
REPORT ZHGUPALL NO STANDARD PAGE HEADING.
************************************************************************
* This is a test program to measure - how much faster a program can
* process it's job if all the other workprocesses are halted.
* The program identifies the dialog and batch workprocesses that are
* running other abaps and sends them a UNIX 24 (halt) signal.
* When it has finished the job, it releases the other workprocesses
* by sending them a signal 26. This method can be hazardous too.
* One such situation can be a deadlock, when the program requires a
* resource, that is locked by an abap that has been paused.
************************************************************************
PARAMETERS: SELFISH.
TABLES: TRDIR.
DATA: T1 TYPE I,
      T2 TYPE I,
      STRING(20) VALUE 'load',
      LOCK(30) VALUE 'kill -24',
      ULOCK(30) VALUE 'kill -26',
      OPCODE TYPE X VALUE 2.
DATA: BEGIN OF LIST OCCURS 10.
        INCLUDE STRUCTURE MSXXLIST.
DATA: END OF LIST.
DATA: BEGIN OF WPLIST OCCURS 10.
        INCLUDE STRUCTURE WPINFO.
DATA: END OF WPLIST.
DATA: BEGIN OF TABL OCCURS 0,
      LINE(200),
END OF TABL.
DATA: BEGIN OF ITAB OCCURS 500,
      LINE(72),
END OF ITAB.
*
* Get the list of dialog workprocesses
CALL FUNCTION 'TH_SERVER_LIST'
     TABLES
          LIST = LIST.
READ TABLE LIST WITH KEY HOST = SY-HOST.
CALL FUNCTION 'TH_WPINFO'
     EXPORTING
          SRVNAME = LIST-NAME
     TABLES
          WPLIST  = WPLIST.
*
* Lock all the DIA and BTC but mine
IF SELFISH = 'Y'.
  LOOP AT WPLIST.
    IF WPLIST-WP_TYP = 'DIA' OR WPLIST-WP_TYP = 'BTC'.
      IF WPLIST-WP_BNAME <> SY-UNAME.
        LOCK+11(8) = WPLIST-WP_PID.
        WRITE: / LOCK.
        CALL 'SYSTEM' ID 'COMMAND' FIELD LOCK
        ID 'TAB'     FIELD TABL-*SYS*.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDIF.
SKIP.
*
* Measure runtime
GET RUN TIME FIELD T1.
*
* This is my processing section VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
SELECT * FROM TRDIR WHERE NAME LIKE 'I%'.
  READ REPORT TRDIR-NAME INTO ITAB.
  LOOP AT ITAB.
    IF ITAB-LINE CS STRING.
      WRITE: / TRDIR-NAME.
      EXIT.
    ENDIF.
  ENDLOOP.
ENDSELECT.
* End of processing ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
************************************************************************
*
* Measure runtime
GET RUN TIME FIELD T2.
T2 = T2 - T1.
SKIP.
WRITE: 'runtime:', T2.
SKIP.
*
* Unock the other guys
IF SELFISH = 'Y'.
  LOOP AT WPLIST.
    IF WPLIST-WP_TYP = 'DIA' OR WPLIST-WP_TYP = 'BTC'.
      IF WPLIST-WP_BNAME <> SY-UNAME.
        ULOCK+11(8) = WPLIST-WP_PID.
        WRITE: / ULOCK.
        CALL 'SYSTEM' ID 'COMMAND' FIELD ULOCK
        ID 'TAB'     FIELD TABL-*SYS*.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDIF.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Performance tuning | Производительность All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.