Last mod: 2024.12.09

Checking performance from bash

Bash utilities in Linux are powerful, lightweight, and highly versatile tools designed for system monitoring, performance analysis, and troubleshooting. They are integral for both real-time and historical system insights, enabling efficient management of resources like CPU, memory, disk, and network. These tools are crucial for administrators and developers to ensure system stability, optimize performance, and quickly diagnose issues.

Sysbench

Sysbench can test performance:

  • File I/O test
  • CPU performance test
  • Memory functions speed test
  • Threads subsystem performance test
  • Mutex performance test
  • MySQL driver performance test
  • PostgreSQL driver performance test

Installation:

sudo apt install sysbench

Single-core test:

sysbench --test=cpu --cpu-max-prime=50000 --time=60 --num-threads=1 run

Multi-core test:

sysbench --test=cpu --cpu-max-prime=50000 --time=60 --num-threads=$(nproc) run

hdparm - HDD/SSD storge tests

Install command line utilities to set and view hardware parameters and also can be used as a simple benchmarking tool:

sudo apt install hdparm -y

And run disk performance test:

sudo hdparm -tT /dev/sda

sudo hdparm -tT /dev/sda

Where options:

  • t - perform device read timings
  • T - perform cache read timings
  • /dev/sda - disk name in system

We can read detailed information about the drive, including SMART:

sudo hdparm -I /dev/sda

sudo hdparm -I /dev/sda

iPerf3 - network performance

To measure network transfers between our two hosts, we can use iperf3. The application must be installed on the two hosts between which we will be checking bandwidth:

sudo apt-get install iperf3

On one of the machines, we need to install the app in server mode:

iperf3 -s

It will listen on port 5201 by default:

iperf3 -s

We can also run temporarily or permanently using systemctl:

sudo systemctl start iperf3    # service start
sudo systemctl status iperf3   # check service status
sudo systemctl stop iperf3     # service stop

sudo systemctl enable iperf3   # enable pernamently, automatically started on startup of the system
sudo systemctl disable iperf3  # disable pernamently

From the second host, we call the command indicates to the IP address of the first machine:

iperf3 -c $REMOTE_SERVER_IP

iperf3 -c 192.168.3.110

Commercial Geekbench

If we would like to compare our synthetic results with other computers then Geekbench is a good choice. Here we have the possibility to run both a free version and a more complex commercial.

Geekbench can be downloaded from the official website https://www.geekbench.com/. Instructions for installing and running the app can be found on the official website.

After launch, the application will perform a series of tests by default and generate link to page where our results will be saved:

./geekbench_x86_64

Example link with results: https://browser.geekbench.com/v6/cpu/9335877