🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.perl.misc
Article #263

Re: Most efficient method to call a system routine and capture it's output

#263
From: Darren Dunham
Date: Fri, 19 Jul 2002 15:54
38 lines
2979 bytes
Ralph SOBEK <sobek@iritremovespam.fr> wrote:
> 	What is the most efficient method to call a system routine
> repeatedly and capture it's short output?

> 	Supposedly, in loop:

> #1	system @cmd;

> is efficient.  But using backquotes:

> #2	(my $sum = `@cmd 2>/dev/null`) =~ s/\s+.*$//;

> captures the output correctly, but is horrendously slow, if repeated a
> couple of thousand times.  For 35,000 files count about SIX hours!

Number of files may be relevant, but /usr/ucb/sum will run in time
proportional to the size of the files.  If those are huge files, that
may be normal.  You can't run faster than 'sum' takes, and I would
imagine any inefficiency in the perl is *swamped* by the time the sum
takes.

How long does it take outside of perl?

find /your/directory/here -exec /usr/ucb/sum {} \;
 
> 	Is there a possibility to prepare the fork in #1 in such a way
> as to recover the forks output afterwards?  It may help to know that
> the output consists only of two numbers.

> 	In fact, in the above I am using File::Find to recursively
> checksum a file structure.  @cmd[0] = '/usr/ucb/sum' and @cmd[1] is
> the file path.

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >
Technical Details
Message-ID: <3DWZ8.2979$WY3.113424663@newssvr21.news.prodigy.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cpk-news-hub1.bbnplanet.com!news.gtei.net!newsfeed.cwix.com!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr21.news.prodigy.com.POSTED!84d38936!not-for-mail
References: <ausn2ib8ny.fsf@irit.irit.fr> <aud6tjbw4d.fsf@irit.irit.fr>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 112333,d48ce9f80ca98172
X-Google-Attributes: gid112333,public
X-Google-Thread: fa0ae,4cb838d93b34e411
X-Google-Attributes: gidfa0ae,public
X-Google-ArrivalTime: 2002-07-19 09:11:10 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cpk-news-hub1.bbnplanet.com!news.gtei.net!newsfeed.cwix.com!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr21.news.prodigy.com.POSTED!84d38936!not-for-mail
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Most efficient method to call a system routine and capture it's output
Newsgroups: comp.lang.perl.misc,fr.comp.lang.perl
References: <ausn2ib8ny.fsf@irit.irit.fr> <aud6tjbw4d.fsf@irit.irit.fr>
User-Agent: tin/1.4.4-20000803 ("Vet for the Insane") (UNIX) (Linux/2.2.14-VA.2.1smp (i686))
Lines: 38
Message-ID: <3DWZ8.2979$WY3.113424663@newssvr21.news.prodigy.com>
NNTP-Posting-Host: 63.104.116.5
X-Complaints-To: abuse@prodigy.net
X-Trace: newssvr21.news.prodigy.com 1027094079 ST000 63.104.116.5 (Fri, 19 Jul 2002 11:54:39 EDT)
NNTP-Posting-Date: Fri, 19 Jul 2002 11:54:39 EDT
Organization: Prodigy Internet http://www.prodigy.com
X-UserInfo1: [[PAPDCA[S@[R\PXFJK^OTTDEB\@PD\MNPWZKB]MPXHJUZ]CDVW[AKK[J\]^HVKHG^EWZHBLO^[\NH_AZFWGN^\DHNVMX_DHHX[FSQKBOTS@@BP^]C@RHS_AGDDC[AJM_T[GZNRNZAY]GNCPBDYKOLK^_CZFWPGHZIXW@C[AFKBBQS@E@DAZ]VDFUNTQQ]FN
Date: Fri, 19 Jul 2002 15:54:39 GMT