Using the Julia script analyze_runtime.jl, we can compare the different runtimes of the command-line parsers (with the --exit flag to exit prior running process_html_template.sh). The violin plots of 10000 iterations each are shown in the following figure:
Fig. 1: Violin plot of all command-line parsers' runtimes.
The runtime statistics are given in the following table:
Tab. 4: Runtimes of all command-line parsers.
| Parser | Mean | Std dev | Median |
|---|---|---|---|
| getopts | 1.6 | 0.5 | 2.0 |
| getopt | 3.8 | 1.5 | 3.0 |
| shFlags | 265.9 | 38.9 | 278.0 |
| docopts | 12.5 | 3.4 | 12.0 |
| Shell Argparser | 123.6 | 1.9 | 123.0 |
As you can see, and unsurprisingly, the runtimes of the compiled programs (docopts, getopt, and getopts) is far lower than that of the interpreted programs (argparser and shflags). Nonetheless, even the two Bash scripts achieve a runtime of less than 150 and 300 ms each. Thereby, the median runtime of the Argparser is lower (and more repeatable) than that of shFlags, while the tool offers far more features. This can be attributed to the design decision of using only Bash builtins within the Argparser, whereas shFlags forks into multiple subshells for external programs and even functions.
For usual scripts, the runtime overhead of the command-line parsing should be negligible, compared to the actual script's runtime, such that the various tools can be chosen by their set of features, and not their runtime.