You are not logged in.

#1 2008-10-03 06:55:10

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Calling external applications from within a script.

Whenever I write scripts that require some external application for functionality, I try to open a pipe or start a server so that I only have to start the external application once. I expect that to reduce overhead and consider it good form. However, sometimes there just isn't any way to avoid calling an external application multiple times and when that happens, I try to find some other workaround if I think it's going to get called repeatedly.

What I'm wondering is how much it really matters for very small and simple programs. The one I have in mind right now is "du". I need to use it in a Perl script because Perl's operators to get file sizes return the apparent size which, in this case, is much larger than the actual size reported back by "du". I'm monitoring the size of files in real-time and I need to call "du" during each iteration of the status updater. Even though I'm passing all the file paths at once, "du" may be called a few times every second (well, I could limit it to once a second).

Could this possibly make any noticeable different on older machines? In general, what external apps can you get away with calling repeatedly?


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#2 2008-10-03 14:31:10

kamituel
Member
From: Poland
Registered: 2006-09-14
Posts: 47
Website

Re: Calling external applications from within a script.

I'm not sure, but I thing that overhead caused by calling du cannot be big enough to matter even on older machines.
But, when calling du from Perl script you are also invoking shell, and this can be a little bit more 'heavy'.


I tried, I failed, no matter. Try again, fail again, fail better.

Offline

Board footer

Powered by FluxBB