[asterisk-users] Benchmarking AGI performance in C, PHP, and Perl

Vincent Sweeney vince at quakenet.co.uk
Mon Jul 11 20:23:10 CDT 2011


On 11/07/11 23:42, Steve Edwards wrote:
>> On 12/07/11 9:29 AM, Steve Edwards wrote:
>
>>> Many times, I've made the statement that you can execute hundreds of 
>>> AGIs written in C in the time it takes to load an interpreter and 
>>> parse a script written in PHP or Perl.
>
> Well, now that I know better, let's not perpetuate an ancient claim. 
> 'Dozens' is more appropriate with current hardware.
>
> On Tue, 12 Jul 2011, Matt Riddell wrote:
>
>> It would be interesting to see the same types of tests run against 
>> fast-agi - personally if I write an agi that will be called 1000 
>> times I'm going to leave it running and have network requests against 
>> it rather than starting and stopping every time.
>
> Isn't every AGI going to be executed 1,000s of times over it's lifetime?
>
> 'Standalone' AGIs still have advantages in lower complexity and less 
> impact on failure. If a bug takes out your fastagi daemon it can 
> affect all calls.
>

I'm pretty sure if you have a bug in your AGI code it's going to affect 
all calls whether its fastagi or not.

> Unless the bits between the AGI and DB calls are significant, there 
> should be no significant difference between source languages in a 
> fastagi environment.
>
> One of my other objections to scripting languages are that they don't 
> 'catch' stupid errors for me (like a misspelled variable name) as well 
> as compiled languages. 'gcc -Wall' is my friend.
>
> Also they tend to be used more by 'non-programmers' who get away with 
> 'stupid' stuff like calling out to system() and piping a bunch of 
> commands together because they don't know how to use the language 
> properly :)
>
>> Mind if I post it to the Daily Asterisk News?
>
> You have my permission.
>

In a production environment any code will have gone through a testing 
phase, so your argument about a compiled language detecting stupid 
errors is pretty much irrelevant. Also most critical bugs will be in the 
script logic not the syntax.

I'm also curious why you think the poor performance of a scripting 
language actually matters for AGI code? As stated most of the time will 
be spent by Asterisk streaming audio / waiting for a prompt. The few 
extra milliseconds a php script takes to start up are not going to be 
noticeable by any human listening to the call.

Vince.



More information about the asterisk-users mailing list