bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: efficient way to use matched string in variable substitution


From: L A Walsh
Subject: Re: efficient way to use matched string in variable substitution
Date: Tue, 24 Aug 2021 13:18:53 -0700
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)



On 2021/08/24 05:06, Greg Wooledge wrote:
Looks like the efficiency of "read -ra" vs. a shell loop just about makes
up for the system calls used for the here string (f6 and f7 are almost
tied in overall speed, with f6 just a *tiny* bit faster).  Good to know.

----
If you set your TIMEFORMAT -- I put this in my login scripts:
export TIMEFORMAT="%2Rsec %2Uusr %2Ssys (%P%% cpu)"

the 4th field can give a feel for parallelism:

fn1() { /usr/bin/ls -1 /usr/bin >/tmp/tt && wc </tmp/tt && rm /tmp/tt ; } fn2() { /usr/bin/ls -1 /usr/bin | wc ; }
time fn1 >/dev/null
0.01sec 0.01usr 0.00sys (101.56% cpu)
time fn2 >/dev/null
0.01sec 0.00usr 0.00sys (134.03% cpu)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]