[FX.php List] Performance Puzzle

Glyn Devine glyn.devine at quickseries.com
Mon Dec 3 13:12:57 MST 2012


Hello all,

Recently I have been building an application to interpret live call data
from the office PBX. I've written it as a PHP script which for now I simply
run from the command line in a terminal window. In the future I am going to
use the System_Daemon PEAR module to turn it into a background service, but
I digress...

Currently, the script is functional, but slow. It establishes a TCP
connection to the PBX and reads and interprets the log data the PBX sends,
which it then formats and submits to a FileMaker table. At first, this
script was performing extremely well. I'd guess that within 0.25 seconds of
receiving the log data the record was successfully created in FM. After I
let it run over the weekend, the time has increased by quite a bit - there's
about a 3-5 second delay before the interpreted data turns into a record.

I've ended and restarted the script (CTRL-C) but the performance issues
remain. Here's the meat of the script (I have replaced identifying
information with XXX):

            $loginfo[0] = trim(substr($r, 0, 4)); //TENANT
            $loginfo[1] = trim(substr($r, 5, 3)); // EXT
            $loginfo[2] = trim(substr($r, 10, 4)); // AUTH
            $loginfo[3] = trim(substr($r, 15, 3)); // TRK
            $loginfo[4] = substr($r, 20, 5); // MM/DD
            $loginfo[5] = substr($r, 26, 8); // STT.TIME
            $loginfo[6] = substr($r, 35, 8); // DURATION
            $loginfo[7] = trim(substr($r, 44, 2)); // FG
            $loginfo[8] = trim(substr($r, 47, 18)); // DIALED DIGIT
            $loginfo[9] = substr($r, 66, 12); // ACCOUNT CODE
            $loginfo[10] = substr($r, 81, 14); // CID/ANI NUMBER
            $loginfo[11] = substr($r, 98, 19); // CID/ANI NAME

            $newrecord = new FX('192.168.X.XXX', '80', 'FMPro9');
            $newrecord->SetDBData('XXX.fp7', 'SMDR');
            $newrecord->SetDBUserPass('XXX', 'XXX');
            $newrecord->AddDbParam('One', $loginfo[0]);
            $newrecord->AddDbParam('Extension', $loginfo[1]);
            $newrecord->AddDbParam('Auth', $loginfo[2]);
            $newrecord->AddDbParam('Trunk', $loginfo[3]);
            $newrecord->AddDbParam('Date', $loginfo[4]);
            $newrecord->AddDbParam('Time', $loginfo[5]);
            $newrecord->AddDbParam('Duration', $loginfo[6]);
            $newrecord->AddDbParam('CallType', $loginfo[7]);
            $newrecord->AddDbParam('DialedNumber', $loginfo[8]);
            $newrecord->AddDbParam('AccountCode', $loginfo[9]);
            $newrecord->AddDbParam('CallerIDNumber', $loginfo[10]);
            $newrecord->AddDbParam('CallerIDName', $loginfo[11]);
            $newrecord->AddDbParam('RawSMDR', $r);
            $result = $newrecord->FMNew();

The first block takes $r, the log entry from the PBX, and splits it up into
field data stored in the $loginfo array. Second part adds to filemaker. This
is in a while loop.

Is there some problem with repeatedly instantiating FX ? Should I
instantiate once then just loop AddDbParam and FMNew ? This script is
running on the same machine that's running my FileMaker Server Advanced 11,
and CPU and/or RAM do not seem to be being taxed to any serious degree. I'm
left to conclude that either FX is slow to add records or for whatever
reason FMS is the limiting factor here... Help me speed this up?

Thanks for your attention and hopefully this isn't too much of a wall of
text to get a reply.

Glyn


        




More information about the FX.php_List mailing list