Module Name:    src
Committed By:   kre
Date:           Thu Sep 10 22:51:11 UTC 2020

Modified Files:
        src/external/bsd/atf/dist/atf-sh: libatf-sh.subr

Log Message:
Replace a pipe into tr to normalise a var name (convert '.' or '-'
into '_' to meet sh variable name rules) into a shell string processing
loop.

On my test system, this reduces the total elapsed time for the bin/sh ATF
tests from about 109 secs to about 102 (user cpu from 24.5 to 21, sys cpu
from 34 to 30) and the usr.bin/make tests elapsed time from 42.5 to 40
secs (user from a bit over 15 to a bit over 13, and sys from 16+ to 13+).
(Recorded on an AMD64 domU).

These probably exaggerate the effect, as there are a bunch of quite small
tests, which means the ATF overhead (which this change affects) is a greater
proportion of the total test time than for some other tests where most of
the time is spent actually testing.

But I am fairly confident that there will be at least some improvement.

This could be further improved by removing the cmdsub invocation method,
and instead passing the name of a variable containing the string to
normalise (with the result returned in that same var) - but that would
mean altering all the callers as well.   Some other time maybe.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/atf/dist/atf-sh/libatf-sh.subr
diff -u src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.4 src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.5
--- src/external/bsd/atf/dist/atf-sh/libatf-sh.subr:1.4	Wed Dec 30 22:23:02 2015
+++ src/external/bsd/atf/dist/atf-sh/libatf-sh.subr	Thu Sep 10 22:51:10 2020
@@ -544,7 +544,15 @@ _atf_list_tcs()
 #
 _atf_normalize()
 {
-    echo ${1} | tr .- __
+    while :
+    do
+	case "${1}" in
+	(*.*)	set -- "${1%.*}_${1##*.}";;
+	(*-*)	set -- "${1%-*}_${1##*-}";;
+	(*)	break;;
+	esac
+    done
+    printf "%s\n" "$1"
 }
 
 #

Reply via email to