Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
~ $ mksh /dev/fd/3 3<<EOF
\${BASH_VERSION+shopt -s expand_aliases}
alias slow-ass-loop='for x in $(printf '%s ' {1..1000000}); do :; done'
foo1() { for x in {1..1000000}; do :; done; }
foo2() { slow-ass-loop; }
unalias -a
time foo1; time foo2
EOF
0m0.01s real 0m0.01s user 0m0.00s system
0m0.45s real 0m0.45s user 0m0.00s system
~ $ ksh /dev/fd/3 3<<EOF
\${BASH_VERSION+shopt -s expand_aliases}
alias slow-ass-loop='for x in $(printf '%s ' {1..1000000}); do :; done'
foo1() { for x in {1..1000000}; do :; done; }
foo2() { slow-ass-loop; }
unalias -a
time foo1; time foo2
EOF
real 0m0.56s
user 0m0.50s
sys 0m0.05s
real 0m0.15s
user 0m0.15s
sys 0m0.00s
~ $ bash /dev/fd/3 3<<EOF
\${BASH_VERSION+shopt -s expand_aliases}
alias slow-ass-loop='for x in $(printf '%s ' {1..1000000}); do :; done'
foo1() { for x in {1..1000000}; do :; done; }
foo2() { slow-ass-loop; }
unalias -a
time foo1; time foo2
EOF
real 0m1.267s
user 0m1.252s
sys 0m0.015s
...got tired of waiting for bash after 5 minutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.