On 2020-11-27 11:37, Achim Gratz wrote:
Mark Geisert writes:
Still faster than two system commands :-).  But thanks for the
comment;

It still seems you are barking up the wrong tree.

I thought I was merely grouping args, to get around Perl's
greedy arg list building for the system command.

Wot?  It just takes a list which you can build any which way you desire.
The other option is to give it the full command line in a string, which
does work for this script (but not on Windows).  If it finds shell
metacharacters in the arguments it'll run a shell, otherwise the forked
perl just does an execve.

If it's really the forking that is causing the slowdown, why not do
either of those things:

a) Generate a complete shell script and fork once to run that.

b) Open up two pipes to an "xargs -P $ncpu/2 L 1 …" and feed in the file
names.

Getting the error codes back to the script and handling the error is
left as an exercise for the reader.

Use explicit binary paths to avoid path search overhead; for portability: /bin/ for base system, dir, file, and net utils including compressors, grep, and sed; /usr/bin/ otherwise; {/usr,}/sbin/ for some admin utils not elsewhere.

--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

Reply via email to