echo 'sleep 0.01' >> ~/.bashrc # or ~/.bash_profile
The big one is that Homebrew is abnormally slow in general and they had multiple commands running homebrew in subshells.
However I have tried to benchmark bash against zsh, to see if one of them is faster.
The benchmark was inconclusive, because I have tried 2 scripts, but the execution times were essentially the same for both bash and zsh.
The 2 scripts invoked a small shell script on each of about ten thousand files and various file attributes were tested and compared in some shell conditional expressions.
Because the times were the same for bash and zsh, it is likely that the file operations dominated the execution time and not the shell startup time or the script interpretation, as I expected.
The shorter benchmark corresponded to an execution time of about 10 millisecond per shell script, so this is an upper limit for the bash startup time in non-interactive mode on my computer.
It is likely that the startup time was several times less.
In conclusion, the startup of bash in non-interactive mode, when it does not source .bashrc or other scripts, is no more than a few millisecond.
It is clear that someone who wants bash to start fast should be able to reach a startup time much, much less than a second.
On the other hand, thank God it wasn't that kind of startup.
I would be curious if mksh is also faster. ksh93 also claims great performance increases, but it is no longer (well) maintained.
"Therefore, many interactive features are not present in Dash, making it faster and more memory efficient than Bash."
Um, no? Debian changed what /bin/sh is, which is what many shell scripts use, especially those startup scripts used by sysvinit. The shell of the root user remains, AFAIK, /bin/bash.
(I think it allowed bashisms even when called as sh)
mksh `printf` is not builtin, so if the script makes heavy use of it then it tends to be slower than bash.
ksh is very interesting because it has the ability to avoid spawning new processes on most command susbstitutions, making it usually much faster than all other POSIX shells.
But again this depends heavily on what the script being executed is doing, here's a highlight of what I described:
$ time mksh -c 'for i in $(seq 1000); do printf $(printf $(printf $(printf hello))); done' > /dev/null
$ time ksh -c 'for i in $(seq 1000); do printf $(printf $(printf $(printf hello))); done' > /dev/null
$ time dash -c 'for i in $(seq 1000); do printf $(printf $(printf $(printf hello))); done' > /dev/null
$ time bash -c 'for i in $(seq 1000); do printf $(printf $(printf $(printf hello))); done' > /dev/null
Funny, I thought my startup time was going to be ginormous, considering I've literally committed to it 203 times so far. Nope, 1.4 to 4.3 ms.
Update: Eyeballing the startup time it's definitely over a second, so I'm guessing OP is measuring something different from what I'm seeing. `hyperfine bash` is also below 5 ms, so I'm not sure how to measure actual startup time. `hyperfine 'bash -i'` does the trick, showing ~650 ms startup times. Turns out another blogger found this already :)
I've had good results with https://github.com/justjanne/powerline-go in the past.