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

Steve Edwards asterisk.org at sedwards.com
Tue Jul 12 15:38:21 CDT 2011


On Tue, 12 Jul 2011, Matthew J. Roth wrote:

> I recognized the code you posted. It's mine:
>
> Thank goodness you didn't try to embarrass me.

Thank you for acknowledging that it was not my intent.

> You just used my code as an example of how a "non-programmer" would use 
> a language, called piping commands together "stupid" and an indication 
> of not knowing how to use the language, referred to it as a skeleton in 
> my closet and something that a programmer with the requisites skills and 
> a better grasp of the language wouldn't do.

Which part is not true? I did not say you were stupid, just that 1 line of 
code is. Would you be more comfortable with 'ignorant?' After reading the 
definitions at www.dictionary.com I think it may be more accurate and less 
prone to misinterpretation but I don't know how to say a line of code is 
ignorant.

I think you're being overly sensitive here.

> I guess I am just not a skilled enough programmer to try to help someone 
> out on this list without getting criticized by you at the time
>
> <http://lists.digium.com/pipermail/asterisk-users/2009-September/237755.html>
>
> and again almost two years later.

A man that has caught his first fish can teach the man with an empty net.

You've been harboring this perceived offense in silence for 2 years? I've 
re-read that post several times today and cannot see where I criticized 
you or your code. Please point it out for me.

> Maybe, just maybe, it's possible that some people recognize that your 
> crusade to replace all scripting with compiled C has its virtues, but 
> it's not worth their programming time to save a few seconds of execution 
> time. You've been at this for years and yet scripting languages still 
> exist.

Both compiled and scripting languages have their place. I have a box 
wrench and a ratchet socket even though they both do kind of the same 
thing.

I do a fair bit of scripting, just not on tasks that are repeated 500,000 
times a day.

> Just think how fast Linux would boot if all of the init scripts were 
> rewritten in C and compiled (they probably have some pipes that could be 
> removed, too!!). Of course, it's pretty nice to be able to easily read 
> and modify them, but execution time is all that's important, right?

If I rebooted my box 500,000 times a day, that may be relevant. My box 
does execute 500,000 AGIs a day.

If I was playing the same MP3 500,000 times a day and complaining about 
the performance might you suggest I could (or should) transcode the file 
to SLIN, ULAW, PCM, etc?

> On the other hand, most people will be headed straight to the Advanced 
> Bash Scripting Guide when they see "epoch=${line:0:10}".

I consider that a win-win. I have fed them for the day and inspired them 
to learn to fish better. Two birds, one stone in my book.

I replied to your code post 2 years ago because you warned the original 
recipient that 'it may take a while to complete.'

To me, that's a call to action for a programmer or any kind of engineer.

Part of the reason I feel compelled to post 'improvements' is to 'pay it 
forward' for the programmers that help me learn my craft. Also, if I let 
it be, future readers will happily (ignorantly?) implement this construct 
for eternity.

I'm reminded of one of my favorite jokes.

A husband is observing his wife is preparing their first holiday meal. She 
takes the ham out of the fridge, sets it on the block, hacks off the last 
4 inches and tosses the piece in the trash.

The husband, cognizant of his ignorance in 'the ways of the kitchen' asks 
her why she did this.

She stops, looks quizzically at the ceiling and says "I don't know. I do 
it because my mom always did it.

The husband calls her mom. Her explanation is the same 'I don't know. I do 
it because my mom always did it.

The husband calls the grandmother. Her explanation is 'I don't know why 
they do that. I do it because my oven is too small.'

Almost a year ago, Anthony Messina posted a link to his fax gateway script 
(now at http://messinet.com/trac/wiki/AsteriskFAXGateway). My hubris 
deluded me to think I could make it better. I got 'skooled!'

I made a list of about 20 constructs I had no clue what they did and 
headed out to the 'Advanced Bash-Scripting Guide' 
(http://tldp.org/LDP/abs/html/)

I've incorporated some of what I learned and my Bash scripting is much 
better for it.

I always try to read Tzafrir Cohen's posts because it's obvious he knows 
way more than I do about Unix at a systems level.

Ditto for (in alphabetical order) Gordon Henderson, Kevin P. Fleming, 
Steve Underwood, Tilghman Lesher, Tony Mountifield and many others. We sit 
at the feet of giants.

> But you're out of line using other people's code as examples of bad 
> programming techniques. Unless my code is in a directory on your desktop 
> labeled "Bad (but in NO Way Embarrassing) Programming Examples" it would 
> have been more efficient (see what I did there?) to come up with 
> something on your own.

My sincere apologies. I did not attribute the line of code to you and did 
not intend any offense. It was just the first egregious example relevant 
to Asterisk users that came to mind.

I am truly sorry. I should have spent a little more time looking through 
my own skeletons.

> And repeat after me, "Programmer time is more expensive than processor 
> time." This isn't the 1970s anymore.

Yes and no. This attitude of 'throw more hardware at it' is why we have 
crap software like Windows Vista that can make a rocket ship perform like 
a slug.

If I posted a 1 line change to the Asterisk source code that let you 
handle 10 times as many calls would you say 'No thanks, we've already 
pencilled in another 0 for next years budget?'

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list