Bash is really slow on Windows. See for yourself:
Notice that running a non-builtin command can be two orders of magnitude more expensive on Windows than on Linux. Creating a subshell is also very slow. Running 10 commands could cost as much as a full second, if not more! This is why shell scripts such as configure scripts are incredibly slow on Windows.
The results here are from Cygwin, but those from Mingw are in the same ballpark. This is probably due to the fact that forking is inherently slow on Windows due to the lack of direct support from the OS, so there’s little that can be done to avoid the performance penalty.
Moral of the story? If you are writing shell scripts for Windows, try to avoid making calls to non-builtin commands and avoid making subshells when possible. Unfortunately, there’s not much you can do with only builtin commands. Furthermore, many operations, such as command substitution
$(…) and pipelines
… | … will implicitly spawn subshells. :(
On the bright side,
printf is a builtin command in Bash, so at least you don’t have to choose between
echo for performance reasons (the latter being a portability nightmare).