Benchmark a System's CPU, IO and Memory (with examples)

Benchmark a System's CPU, IO and Memory (with examples)

1: Run a CPU benchmark with 1 thread for 10 seconds

Code:

sysbench cpu run

Motivation: Running a CPU benchmark helps to measure the performance of the processor and understand how well it can handle intensive workloads. The sysbench cpu run command is used to execute a CPU benchmark with a single thread for a duration of 10 seconds.

Explanation: The sysbench cpu run command initiates the CPU benchmark process with default settings. It uses one thread to stress the CPU for a specified duration. This benchmark calculates the maximum number of prime numbers a CPU can calculate within the given time frame.

Example Output:

Running the test with following options:
Number of threads: 1
Initializing random number generator from /dev/urandom.
Prime numbers limit: 10000
Initializing worker threads...

Threads started!

CPU speed:
    events per second:   153.96

General statistics:
    total time:                          10.0007s
    total number of events:              1539

Latency (ms):
         min:                                   6.05
         avg:                                   6.51
         max:                                   7.40
         95th percentile:                       6.92
         sum:                                10005.50

Threads fairness:
    events (avg/stddev):           1539.0000/0.00
    execution time (avg/stddev):   10.0055/0.00

2: Run a CPU benchmark with multiple threads for a specified time

Code:

sysbench --threads=4 --time=20 cpu run

Motivation: Running a CPU benchmark with multiple threads is useful to measure the performance of a processor in a multi-threaded workload scenario. The sysbench --threads=4 --time=20 cpu run command starts a CPU benchmark with four threads and runs it for 20 seconds.

Explanation: The sysbench command is used to initiate the benchmark process. The --threads argument specifies the number of threads to be used during the benchmark. In this example, we are using four threads. The --time argument defines how long the benchmark should run, which is 20 seconds in this case.

Example Output:

Initializing random number generator from /dev/urandom.

Running the test with following options:
Number of threads: 4
Initializing worker threads...

Threads started!

CPU speed:
    events per second:   759.30

General statistics:
    total time:                          20.0001s
    total number of events:              15187

Latency (ms):
         min:                                  16.53
         avg:                                  26.32
         max:                                  35.28
         95th percentile:                      31.07
         sum:                               400102.00

Threads fairness:
    events (avg/stddev):           3796.7500/244.34
    execution time (avg/stddev):   100.0255/6.26

3: Run a memory benchmark with 1 thread for 10 seconds

Code:

sysbench memory run

Motivation: Running a memory benchmark helps evaluate the memory subsystem performance of a system. The sysbench memory run command executes a memory benchmark with one thread for 10 seconds.

Explanation: The sysbench memory run command initiates the memory benchmark process with default settings. It creates a memory workload that exercises the system’s memory subsystem by performing memory allocations, filling and emptying memory blocks, and verifying memory integrity for specified durations.

Example Output:

Running the test with following options:
Number of threads: 1
Initializing random number generator from /dev/urandom.
Operations performed: 0
Read block size: 1KiB
Write block size: 1KiB
Memory operations type: write
Memory scope type: global
Threads started!

General statistics:
    total time:                          10.0020s
    total number of events:              82155

Latency (ms):
         min:                                   0.00
         avg:                                   0.12
         max:                                  31.79
         95.00th percentile:                    0.21
         sum:                                9654.92

Threads fairness:
    events (avg/stddev):           82155.0000/0.00
    execution time (avg/stddev):   9.6549/0.00

4: Prepare a filesystem-level read benchmark

Code:

sysbench fileio prepare

Motivation: Preparing a filesystem-level read benchmark allows us to simulate disk read operations in order to evaluate the performance of the storage system. The sysbench fileio prepare command prepares the necessary files and directories for running a filesystem-level read benchmark.

Explanation: The sysbench fileio prepare command creates a set of files and directories that will be used during the filesystem-level benchmark. It is necessary to prepare the benchmark before executing it in order to have the required files and directories ready for testing.

Example Output:

Creating data file...

prepare.sh: Done preparing.

5: Run a filesystem-level benchmark

Code:

sysbench --file-test-mode=rndrd --num-threads=8 fileio run

Motivation: Running a filesystem-level benchmark helps measure the performance of the storage subsystem, such as the I/O throughput, latency, and access pattern of disk operations. The sysbench --file-test-mode=rndrd --num-threads=8 fileio run command runs a filesystem-level benchmark with random read (rndrd) mode using eight threads.

Explanation: The sysbench command is used to initiate the filesystem-level benchmark process. The --file-test-mode argument specifies the type of benchmark to run. In this example, we are using the random read (rndrd) mode. The --num-threads argument defines the number of threads participating in the benchmark, which is eight in this case.

Example Output:

Running the test with following options:
Number of threads: 8
Initializing random number generator from current time

Extra file open flags: 0
128 files, 256MiB each
32GiB total file size
Block size 16KiB
Random read test with single thread
Using synchronous I/O mode
Initializing worker threads...

Threads started!

File operations:
    reads/s:                      3393.97
    read, MiB/s:                  52.71
    read, MB/s:                   49.57

General statistics:
    total time:                          10.0009s
    total number of events:              33921

Latency (ms):
         min:                                   2.37
         avg:                                   2.93
         max:                                  19.53
         95th percentile:                       3.93
         sum:                               99348.99

Threads fairness:
    events (avg/stddev):           4240.1250/36.92
    execution time (avg/stddev):   12.4186/0.02

These example use cases illustrate different functionalities of the sysbench command for benchmarking a system’s CPU, IO, and memory. By utilizing these examples, users can evaluate the performance of their systems in order to optimize hardware configurations or identify potential bottlenecks.

Related Posts

How to use the command fzf (with examples)

How to use the command fzf (with examples)

fzf is a command-line fuzzy finder that allows users to quickly search and select items from a list.

Read More
How to use the command 'rmdir' (with examples)

How to use the command 'rmdir' (with examples)

The ‘rmdir’ command is used to remove directories without files. It is similar to the ‘rm’ command, but specifically designed for removing empty directories.

Read More
How to use the command logwatch (with examples)

How to use the command logwatch (with examples)

Logwatch is a command-line tool that helps summarize and analyze various logs for common services.

Read More