Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jun 2007 11:08:04 +0300
From:      Danny Braniss <danny@cs.huji.ac.il>
To:        Garrett Cooper <youshi10@u.washington.edu>
Cc:        hackers@freebsd.org
Subject:   Re: Using shell commands versus C equivalents 
Message-ID:  <E1HykNA-000DN3-7A@cs1.cs.huji.ac.il>
In-Reply-To: <46700CAE.6020902@u.washington.edu> 
References:  <466F86C6.7010006@u.washington.edu> <20070613123213.GE98927@bunrab.catwhisker.org> <E1HySxb-000PIg-89@cs1.cs.huji.ac.il> <46700CAE.6020902@u.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
...
> Sorry -- actually I meant that (along similar lines), there was a 
> program with the following lines:
> 
> vsystem("/bin/chmod +x %s", filename);
> 
> and I replaced it with:
> 
> chmod(filename, (mode_t) ( S_IXUSR | S_IXGRP | S_IXOTH ));
> 
> Probably won't yield much gain overall, but every drop counts and there 
> are quite a few iterations performed in the pkg_* programs, in 
> particular dealing with X.org.

chmod is one(1) system call, while system is many, for starters it's
fork/exec, which btw, is quiet expensive, haven't counted, but my gut feeling
it's in the 10s.
So, if the program does this chmod once in a blue moon, there is no real
argument, but if id does it many times, then one system call is a real winner,

danny





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1HykNA-000DN3-7A>