[FX.php List] Performance Puzzle

Nick whatdoyouwant at gmail.com
Mon Dec 3 20:21:28 MST 2012


also you can save some cpu cycles by using clone (prevents calling the
constructor of the FX class every time):

instantiate once at the top of your script like this:

$db = new FX('192.168.X.XXX', '80', 'FMPro9');
            $db->SetDBData('XXX.fp7', 'SMDR');
            $db->SetDBUserPass('XXX', 'XXX');

then use $newrecord = clone($db); instead of the new FX line and the other
two set in the $db variable.  This works in php 5 without special code.

but yeah like Denis said, look through your code, output some debug lines.
 Maybe check php.net/memory_get_usage and see if that applies to you.  It
might not be other parts of your code like the tcp connection that slow it
down.



On Mon, Dec 3, 2012 at 3:35 PM, Denis Somar <dsomar at gmail.com> wrote:

> I've dealt with issues in similar pieces of code.  For debugging purposes,
> remove each line and test again, iteratively and see which line may be
> causing the speed crunch.
>
> HTH
> Denis
>
>
> On Mon, Dec 3, 2012 at 3:12 PM, Glyn Devine <glyn.devine at quickseries.com>wrote:
>
>> 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
>>
>>
>>
>>
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20121203/3bcfc62a/attachment-0001.html


More information about the FX.php_List mailing list