Using shell commands versus C equivalents
Danny Braniss
danny at cs.huji.ac.il
Thu Jun 14 08:08:08 UTC 2007
...
> 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
More information about the freebsd-hackers
mailing list