56 How to test Linux performance using sysbench ?

Install sysbench which is avaliable in all installation managers.

Use >sysbench --help for help. No man pages?

Then do

>sysbench cpu run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 1 
Initializing random number generator from current time 
 
 
Prime numbers limit: 10000 
 
Initializing worker threads... 
 
Threads started! 
 
CPU speed: 
    events per second:  3983.04 
 
General statistics: 
    total time:                          10.0005s 
    total number of events:              39839 
 
Latency (ms): 
         min:                                    0.23 
         avg:                                    0.25 
         max:                                   20.25 
         95th percentile:                        0.26 
         sum:                                 9943.89 
 
Threads fairness: 
    events (avg/stddev):           39839.0000/0.00 
    execution time (avg/stddev):   9.9439/0.00
 

And

>sysbench memory run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 1 
Initializing random number generator from current time 
 
 
Running memory speed test with the following options: 
  block size: 1KiB 
  total size: 102400MiB 
  operation: write 
  scope: global 
 
Initializing worker threads... 
 
Threads started! 
 
Total operations: 74842059 (7482566.83 per second) 
 
73087.95 MiB transferred (7307.19 MiB/sec) 
 
 
General statistics: 
    total time:                          10.0013s 
    total number of events:              74842059 
 
Latency (ms): 
         min:                                    0.00 
         avg:                                    0.00 
         max:                                   10.37 
         95th percentile:                        0.00 
         sum:                                 4017.76 
 
Threads fairness: 
    events (avg/stddev):           74842059.0000/0.00 
    execution time (avg/stddev):   4.0178/0.00
 

or

>sysbench --threads=5 memory run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 5 
Initializing random number generator from current time 
 
 
Running memory speed test with the following options: 
  block size: 1KiB 
  total size: 102400MiB 
  operation: write 
  scope: global 
 
Initializing worker threads... 
 
Threads started! 
 
Total operations: 89536061 (8944801.69 per second) 
 
87437.56 MiB transferred (8735.16 MiB/sec) 
 
 
General statistics: 
    total time:                          10.0028s 
    total number of events:              89536061 
 
Latency (ms): 
         min:                                    0.00 
         avg:                                    0.00 
         max:                                   46.68 
         95th percentile:                        0.00 
         sum:                                27564.97 
 
Threads fairness: 
    events (avg/stddev):           17907212.2000/1640514.61 
    execution time (avg/stddev):   5.5130/0.11
 

or

 
>sysbench --threads=5 cpu run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 5 
Initializing random number generator from current time 
 
 
Prime numbers limit: 10000 
 
Initializing worker threads... 
 
Threads started! 
 
CPU speed: 
    events per second:  6707.45 
 
General statistics: 
    total time:                          10.0036s 
    total number of events:              67111 
 
Latency (ms): 
         min:                                    0.23 
         avg:                                    0.74 
         max:                                   56.90 
         95th percentile:                        2.22 
         sum:                                49553.41 
 
Threads fairness: 
    events (avg/stddev):           13422.2000/856.28 
    execution time (avg/stddev):   9.9107/0.03
 

And

>sysbench --threads=5 --file_test_mode="seqwr" fileio run 
sysbench 1.0.20 (using system LuaJIT 2.0.5) 
 
Running the test with following options: 
Number of threads: 5 
Initializing random number generator from current time 
 
 
Extra file open flags: (none) 
128 files, 16MiB each 
2GiB total file size 
Block size 16KiB 
Periodic FSYNC enabled, calling fsync() each 100 requests. 
Calling fsync() at the end of test, Enabled. 
Using synchronous I/O mode 
Doing sequential write (creation) test 
Initializing worker threads... 
 
Threads started! 
 
 
File operations: 
    reads/s:                      0.00 
    writes/s:                     36.47 
    fsyncs/s:                     101.22 
 
Throughput: 
    read, MiB/s:                  0.00 
    written, MiB/s:               0.57 
 
General statistics: 
    total time:                          10.1126s 
    total number of events:              753 
 
Latency (ms): 
         min:                                    0.00 
         avg:                                   66.82 
         max:                                  655.80 
         95th percentile:                      337.94 
         sum:                                50315.70 
 
Threads fairness: 
    events (avg/stddev):           150.6000/63.87 
    execution time (avg/stddev):   10.0631/0.04
 

To use on windows go to https://github.com/akopytov/sysbench but need WSL to use.

The compiled tests are

ompiled-in tests: 
  fileio - File I/O test 
  cpu - CPU performance test 
  memory - Memory functions speed test 
  threads - Threads subsystem performance test 
  mutex - Mutex performance test
 

Reference https://linuxconfig.org/how-to-benchmark-your-linux-system