Cost Of A SubShell

bash-3.2$ time (for x in {1..210000}; do : ; done)

real    0m0.934s
user    0m0.911s
sys    0m0.020s


bash-3.2$ time for x in {1..1000}; do (:) ; done

real    0m0.967s
user    0m0.309s
sys    0m0.632s


# The sys cost of forking 1000 times in 0.632 seconds just under a millisecond per subshell.
# to create the subshell. This is a lot more than I would have expected for a naked fork so 
# lots of other stuff is probably going on.

Comments

Popular posts from this blog

oche, lik echo but a bit easier to use.

Bithon: Run Python Interactively Inside Bash

Parsing Columns From Files WITHOUT awk