I'm sorry to keep bugging you, but I'm concerned about slow performance. This may be normal at this stage, but it takes almost 5 seconds for an ajax call to an RPG program that simply increments a counter in a data area and returns the new value. I don't know where the bottleneck is happening, but surely it shouldn't take that long.
Here is my PHP:
- Code: Select all
<?php
require('checkCredentials.php');
require_once('ToolkitService.php');
$ToolkitServiceObj = ToolkitService::getInstance($db, $namingMode);
$ToolkitServiceObj->setToolkitServiceParams(array('InternalKey'=>"/tmp/$user"));
$param[] = $ToolkitServiceObj->AddParameterPackDec('both', 9,0, 'SRN', 'SRN', $srn);
$result = $ToolkitServiceObj->PgmCall("SCNXTSRN", "WWW", $param, null, null);
if($result){
$out = $result['io_param'];
foreach($out as $key=>$value){
$response->srn = $value;
}
echo json_encode($response);
} else {
echo "Execution failed.";
}
/* Do not use the disconnect() function for "state full" connection */
$ToolkitServiceObj->disconnect();
?>
And here is the RPG program that the PHP script calls:
- Code: Select all
//===============================================================*
// Program - SCNXTSRN Get Next System Ref. No.
//===============================================================*
D nextSRN S 9 0 DTAARA('QS36F/SCD004')
//***********************************************************************
C *ENTRY PLIST
C PARM SRN 9 0
//***********************************************************************
/FREE
//Generate SRN
In *lock nextSRN;
srn = nextSRN;
nextSRN += 1;
Out nextSRN;
*InLR = *On;
Return;
/End-Free
...And it might be useful to see the debug.log:
- Code: Select all
************Beginning of data**************
Creating new conn with database: 'Resource id #1', user or i5 naming flag: '1', ext prefix: '', persistence: ''
Re-using an existing db connection with schema separator: /
Exec start: 2012-04-06 13:12:25
IPC: '/tmp/ADAM'. Control key: *cdata *sbmjob(ZENDSVR/ZSVR_JOBD/XTOOLKIT)
Stmt: call ZENDSVR/iPLUG512K(?,?,?,?)
Input XML: <?xml version="1.0" encoding="ISO-8859-1" ?><script>
<pgm name='SCNXTSRN' lib='WWW'>
<parm comment='SRN' io='both'> <data type='9p0' var='SRN' ></data> </parm>
</pgm>
</script>
Output XML: <?xml version="1.0" encoding="ISO-8859-1" ?><script>
<pgm name='SCNXTSRN' lib='WWW'>
<parm comment='SRN' io='both'>
<data type='9p0' var='SRN' ><![CDATA[230619]]></data>
</parm>
</pgm>
</script>
Exec end: 2012-04-06 13:12:27. Seconds to execute: 2.2392559051514.
Exec start: 2012-04-06 13:12:27
IPC: '/tmp/ADAM'. Control key: *immed
Stmt: call ZENDSVR/iPLUG512K(?,?,?,?)
Input XML: <?xml version="1.0" encoding="ISO-8859-1" ?>
Output XML:
Exec end: 2012-04-06 13:12:29. Seconds to execute: 1.6946349143982.
Db disconnect requested and done.
************End of Data********************
I remember hearing Mike Pavlak say that it's most efficient to put the path to the toolkit first in the include_path. I did that, and it shaved about .2 seconds off. Is it supposed to take about 4.5 seconds to make a call to RPG like this?