ShellBench is a free benchmark tool written in a shell script for POSIX shell comparison. It allows you to execute a series of commands in an infinite loop or until the timeout.
This way, you can test and compare the performance of various shells like Sh, Bash, Dash, Zsh, Fish, etc., and upon completion, it will return the number of executions per second, with a higher number indicating better performance.
You can perform this test by either creating your own customized test or using the available eight sample benchmark tests to check the performance across various operations.
In this article, you learn how to setup ShellBench on your Linux system and run tests on several shells at the same time to compare performance.
Tutorial Details
Description | ShellBench |
Difficulty Level | Low |
Root or Sudo Privileges | No |
OS Compatibility | Ubuntu, Manjaro, Fedora, etc. |
Prerequisites | – |
Internet Required | No |
How to Setup Shellbench on Linux
The ShellBench is a shell script written and maintained by ShellSpec and hosted on GitHub. Thus, to use it, you can simply open your terminal and clone the latest file by running.
$ git clone https://github.com/shellspec/shellbench.git
Output:
Once done, navigate to the cloned directory and list its contents by running:
$ cd shellbench/ && ls
Output:
Here, you will see a “shellbench
” script that you can use to benchmark different shells.
Benchmark Test on Different Shells Using ShellBench
To showcase its usage, I’ll conduct a benchmark test on various built-in and external shells installed on my Linux system, followed by.
- POSIX shell (sh)
- Bourne shell (sh)
- Bourne Again Shell (bash)
- Debian Almquist Shell (dash)
- C shell (csh)
- Korn shell (ksh)
- Z shell (zsh)
- Fish shell (fish)
Let’s use the “shellbench
” script to compare the performance of these shells by specifying each shell to the “-s
” flag (separated by commas) and using the sample script that comes with ShellBench itself.
$ ./shellbench -s sh,bash,dash,csh,ksh,zsh,fish sample/*
Once the command is executed, the benchmark test will begin, which will take some time. Once it’s done, you will receive the following output:
In the above picture, you’ll notice errors, particularly in the Csh and Fish columns. This typically occurs when the keywords and commands mentioned in the sample script aren’t supported by that specific shell.
So, in such cases, you need to create your own custom test or find one already available on the internet. For now, we will overlook the test results of these two shells and compare the performance of the rest of the shells in the following graphical representation.
The above bar graph shows the comparison of each shell clearly, and you can see that the fastest shell is a Dash, which easily beats others in almost all the tests, followed by Sh and Bash, and the least performed shell was Zsh, which was barely able to compete with others.
Well, I won’t say that this test result is pinpoint accurate, as there are many other factors involved in benchmarking any software or tool. However, it provides a slight glimpse into the shell optimization, and by observing the fastest one, I can clearly say it’s the quickest shell among others, if you know what I mean.
I’ll end this article here, but if you have any questions or queries about the article, do let me know in the comment section.
Till then, peace!
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.