Easy Peasy Fast XMLSERVICE

PHP RPG
<?php
// -----------------
// Complex massive amount of record data structures
// -----------------
function getxml($recs) {
$clob "<?xml version='1.0'?>\n";
$clob .= "<script>\n";
$clob .= "<pgm name='ZZBIGBOY' lib='CALLPASE'>\n";
$clob .= " <parm  io='both'>\n";
$clob .= "   <data type='7s0' var='STEP1'>$recs</data>\n";
$clob .= " </parm>\n";
$clob .= " <parm  io='both'>\n";
$clob .= " <ds dim='$recs' data='records'>\n";
$clob .= "   <data type='7A' var='NAME1'>nada1</data>\n";
$clob .= "   <data type='7s1'  var='YEARWIN1'>1.0</data>\n";
$clob .= " </ds>";
$clob .= " <records delimit=':'>";
for (
$i=0;$i<$recs;$i++) $clob .= ":nada{$i}:1.0";
$clob .= ":";
$clob .= "</records>\n";
$clob .= " </parm>\n";
$clob .= " <return>\n";
$clob .= "  <data type='10i0'>0</data>\n";
$clob .= " </return>\n";
$clob .= "</pgm>\n";
$clob .= "</script>";
return 
$clob;
}
// -----------------
// make the call
// -----------------
$loop 1;
$bigdata 100000;
$start_time microtime();

$i5persistentconnect false;
$database "*LOCAL";
$user "";
$password "";
$libxmlservice "XMLSERVICE";
if (
$i5persistentconnect$conn db2_pconnect($database,$user,$password);
else 
$conn db2_connect($database,$user,$password);
if (!
$conn) die("Bad connect: $database,$user");
$stmt db2_prepare($conn"call $libxmlservice.iPLUG10M(?,?,?,?)");
if (!
$stmt) die("Bad prepare: ".db2_stmt_errormsg());
$ipc '/tmp/mybigboy100';
$ctl '*sbmjob';
$clobIn getxml($bigdata);
$clobOut "";
$ret=db2_bind_param($stmt1"ipc"DB2_PARAM_IN);
$ret=db2_bind_param($stmt2"ctl"DB2_PARAM_IN);
$ret=db2_bind_param($stmt3"clobIn"DB2_PARAM_IN);
$ret=db2_bind_param($stmt4"clobOut"DB2_PARAM_OUT);
$ret=db2_execute($stmt);
if (!
$ret) die("Bad execute: ".db2_stmt_errormsg());
// -----------------
// output processing
// -----------------
// dump raw XML (easy test debug)
// var_dump($clobIn);
echo "<h1>Calling Big Boy PGM</h1>\n";
echo 
"<h1>$bigdata Records Input/Ouput</h1>\n";
echo 
"<p>Welcome aboard xmlservice toolkit hacker crew, flying $bigdata records round trip.</p>\n";
echo 
"<p>Your flight time today: ";
output_time($start_time);
echo 
"</p>\n";
echo 
"<textarea cols='120' rows='120' readonly='yes'>\n";
var_dump($clobOut);
//echo substr($clobOut,0,400)."\n";
//echo ":\n";
//echo "... ton of data removed to keep your browser happy ...\n";
//echo ":\n";
//echo substr($clobOut,-400)."\n";
echo "</textarea>\n";

function 
output_time($start_time) {
  global 
$loop;
  
$end_time microtime();
  
$wire_timecontrol_microtime_used($start_time,$end_time)*1000000;
  echo 
  
sprintf("Time (loop=$loop) total=%1.2f sec (%1.2f calls/sec) (%1.6f sec per call)\n"
  
round($wire_time/1000000,2),
  
round($loop/($wire_time/1000000),2),
  
round(($wire_time/$loop)/1000000,6));
}
function 
control_microtime_used($before,$after) {
  return (
substr($after,11)-substr($before,11))+(substr($after,0,9)-substr($before,0,9));
}

?>
1
     H AlwNull(*UsrCtl)

     D STEP1           s              7s 0

     D BIGBOY1         ds                  occurs(1000000)
     D NAME1                   1      7
     D YEARWIN1                8     14  1
     d*
     D i               S             10i 0 inz(0)
     D j               S             10i 0 inz(0)
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      * main(): Control flow
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     C     *Entry        PLIST
     c                   parm                    STEP1
     c                   parm                    BIGBOY1
      /free
        for i = 1 to STEP1;
          %OCCUR(BIGBOY1) = i;
          NAME1 = 'B' + %char(i);
          YEARWIN1 = i + .1;
        endfor;
        return;
      /end-free