Peng Yu
2018-11-13 23:27:50 UTC
Hi,
See the following example, the $() with exec seems to be faster the
one without exec. But there is always fluctuation of my test results.
Is the exec version always preferred? (Besides run time, another
benefit I know is it reduce one process as well.)
$ ./main_performance.sh
tmpfile=$(mktemp -u)
time for((i=0;i<1000;++i))
do
x=$(./script.sh)
done # > "$tmpfile"
real 0m9.861s
user 0m2.824s
sys 0m5.488s
tmpfile=$(mktemp -u)
time for((i=0;i<1000;++i))
do
x=$(exec ./script.sh)
done # > "$tmpfile"
real 0m9.525s
user 0m2.781s
sys 0m5.245s
$ cat script.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
echo "$BASHPID"
See the following example, the $() with exec seems to be faster the
one without exec. But there is always fluctuation of my test results.
Is the exec version always preferred? (Besides run time, another
benefit I know is it reduce one process as well.)
$ ./main_performance.sh
tmpfile=$(mktemp -u)
time for((i=0;i<1000;++i))
do
x=$(./script.sh)
done # > "$tmpfile"
real 0m9.861s
user 0m2.824s
sys 0m5.488s
tmpfile=$(mktemp -u)
time for((i=0;i<1000;++i))
do
x=$(exec ./script.sh)
done # > "$tmpfile"
real 0m9.525s
user 0m2.781s
sys 0m5.245s
$ cat script.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
echo "$BASHPID"
--
Regards,
Peng
Regards,
Peng