Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RLA to Embedded SQL Benchmarks #18

Open
worksofliam opened this issue Jul 7, 2019 · 0 comments
Open

RLA to Embedded SQL Benchmarks #18

worksofliam opened this issue Jul 7, 2019 · 0 comments
Labels
ilerpg ILE RPG topics

Comments

@worksofliam
Copy link
Owner

This is part one in a series of blog posts which include benchmarks
after using RLAConverter
to change RLA operations into Embedded SQL. In the next post, I hope to
have a larger example.

In this example we will take a look at SETGT and REAPE. Here is a
diff off the code before and after the conversion.

ctl-opt dftactgrp(*no);

//dcl-f productsp keyed usropn;
Dcl-Ds PRODUCTSP EXTNAME('PRODUCTSP');
End-Ds;

dcl-s start timestamp;
dcl-s end timestamp;
dcl-s data varchar(50);

start = %timestamp();

//open productsp;
EXEC SQL DECLARE c_PRODUCTSP SCROLL CURSOR FOR
  SELECT * FROM PRODUCTSP;
EXEC SQL OPEN c_PRODUCTSP;

//Setgt (115) productsp;
//Readpe (115) productsp;
//If not %Eof(productsp);
SetGTPRODUCTSP(115);
ReadPEPRODUCTSP(115);
//IF NOT %EOF(PRODUCTSP);
If not (sqlstate = '02000');
  data = %Char(PRID);
EndIf;

dsply data;

//close productsp;
EXEC SQL CLOSE c_PRODUCTSP;

end = %timestamp();
       
Dsply %Char(%Diff(end:start:*mseconds));

Return;

Dcl-Proc SetGTPRODUCTSP;
  Dcl-Pi *N;
    pPRID Like(PRID) Const;
  End-Pi;
  EXEC SQL FETCH AFTER FROM c_PRODUCTSP;
  EXEC SQL FETCH PRIOR FROM c_PRODUCTSP INTO :PRODUCTSP;
  Dow NOT (sqlstate = '02000');
    If (pPRID = PRID);
      EXEC SQL FETCH RELATIVE +1 FROM c_PRODUCTSP;
      Return; //Found the record!
    Endif;
    EXEC SQL FETCH PRIOR FROM c_PRODUCTSP INTO :PRODUCTSP;
  Enddo;
End-Proc;
Dcl-Proc ReadPEPRODUCTSP;
  Dcl-Pi *N;
    pPRID Like(PRID) Const;
  End-Pi;
  EXEC SQL FETCH PRIOR FROM c_PRODUCTSP INTO :PRODUCTSP;
  Dow NOT (sqlstate = '02000');
    If (pPRID = PRID and pPRID = PRID);
      Return; //Found the record!
    Endif;
    EXEC SQL FETCH PRIOR FROM c_PRODUCTSP INTO :PRODUCTSP;
  Enddo;
End-Proc;

Results

I called each program three times to see if the programs would perform
better the more times they were ran. While not a huge improvement,
it's neat that it hasn't made it worse.

RLA

> call readpe1 
  DSPLY  115   
  DSPLY  132000
> call readpe1 
  DSPLY  115   
  DSPLY  120000
> call readpe1 
  DSPLY  115   
  DSPLY  119000

Embedded SQL

> call readpe1  
  DSPLY  115    
  DSPLY  120000 
> call readpe1  
  DSPLY  115    
  DSPLY  119000
> call readpe1 
  DSPLY  115   
  DSPLY  117000
@worksofliam worksofliam added the ilerpg ILE RPG topics label Jul 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ilerpg ILE RPG topics
Projects
None yet
Development

No branches or pull requests

1 participant