diff options
| author | Willy Tarreau <w@1wt.eu> | 2021-11-18 15:32:16 +0100 |
|---|---|---|
| committer | Willy Tarreau <w@1wt.eu> | 2021-11-18 17:54:49 +0100 |
| commit | b7a28e7bc854ee1dc08db7c0b43c6fea576a7c46 (patch) | |
| tree | 98cb8c8189a780c78fc88780d4587c57720e1f45 | |
| parent | 0b3eb81c6b67ebca09a8ec01c8125b17d3745ede (diff) | |
| download | haproxy-b7a28e7bc854ee1dc08db7c0b43c6fea576a7c46.tar.gz | |
SCRIPT: run-regtests: avoid calling awk to compute the version
For each test, the version number is evaluated using a call to awk,
which can be slow to start depending on the versions and OS. This is
only needed for a printf() call to keep only leading digits of each
component, multiply them by 1000 and pad them to 3 digits, something
that's clearly doable in plain shell in a portable way. This is what
this patch does, and it saves yet another 400 ms here on the full
test sequence.
| -rwxr-xr-x | scripts/run-regtests.sh | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/scripts/run-regtests.sh b/scripts/run-regtests.sh index 1af935075..5126efb3f 100755 --- a/scripts/run-regtests.sh +++ b/scripts/run-regtests.sh @@ -301,8 +301,13 @@ _process() { done } +# compute a version from up to 4 sub-version components, each multiplied +# by a power of 1000, and padded left with 0, 1 or 2 zeroes. _version() { - echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\012", $1,$2,$3,$4); }'; + OLDIFS="$IFS"; IFS="."; set -- $*; IFS="$OLDIFS" + set -- ${1%%[!0-9]*} 000${2%%[!0-9]*} 000${3%%[!0-9]*} 000${4%%[!0-9]*} + prf2=${2%???}; prf3=${3%???}; prf4=${4%???} + echo ${1}${2#$prf2}${3#$prf3}${4#$prf4} } |
