[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What tricks used in readlink to make it faster than realpath bash loadab
From: |
Peng Yu |
Subject: |
What tricks used in readlink to make it faster than realpath bash loadable? |
Date: |
Thu, 13 Dec 2018 15:37:04 -0600 |
Hi,
`readlink` is faster than `realpath` for a large number of input
arguments. Note that the former starts slower than the latter. What
tricks is used in readlink to make it faster? Thanks.
https://github.com/bminor/bash/blob/master/examples/loadables/realpath.c
bash> builtin enable -f
~/Downloads/bash-4.4/examples/loadables/realpath realpath
bash> type realpath
realpath is a shell builtin
bash> type readlink
readlink is /usr/local/opt/coreutils/libexec/gnubin/readlink
bash> readlink -e . > /dev/null
real 0m0.014s
user 0m0.003s
sys 0m0.006s
bash> realpath . > /dev/null
real 0m0.003s
user 0m0.001s
sys 0m0.002s
bash> readlink -e $(printf '. %.0s' {1..10000}) > /dev/null
real 0m0.200s
user 0m0.078s
sys 0m0.121s
bash> realpath $(printf '. %.0s' {1..10000}) > /dev/null
real 0m0.211s
user 0m0.105s
sys 0m0.103s
--
Regards,
Peng
- What tricks used in readlink to make it faster than realpath bash loadable?,
Peng Yu <=