← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~smoser/cloud-init:fix/1771382-ds-identify-ensure-sane-path into cloud-init:master

 

Just to write this down somewhere... the adding paths and searching (as compared to just appending PATH=$PATH:/usr/bin:....) doesnt cost a lot of time.

### Running ":" 100k times as benchmark
$ time sh /tmp/my.sh "/my/random:/path:/here" : $(seq 1 100000)
/my/random:/path:/here

real	0m0.162s
user	0m0.133s
sys	0m0.032s


### Running ensure_sane_path 100k times.
$ time sh /tmp/my.sh "/my/random:/path:/here" ensure_sane_path $(seq 1 100000)
/my/random:/path:/here:/sbin:/usr/sbin:/bin:/usr/bin

real	0m0.586s
user	0m0.543s
sys	0m0.045s

### Run with a larger input path.
$ time sh /tmp/my.sh "$PATH" ensure_sane_path $(seq 1 100000)
/home/smoser/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/var/lib/snapd/snap/bin

real	0m0.635s
user	0m0.611s
sys	0m0.026s


So the cost of 100000 runs of ensure_sane_path is somewhere in the realm
of .5 seconds.  That is .000005 for the one run we'll do.

very small.

-- 
https://code.launchpad.net/~smoser/cloud-init/+git/cloud-init/+merge/345786
Your team cloud-init commiters is requested to review the proposed merge of ~smoser/cloud-init:fix/1771382-ds-identify-ensure-sane-path into cloud-init:master.


References