Home Article Stress Testing a Raspberry Pi with Sysbench

Stress Testing a Raspberry Pi with Sysbench

by shedboy71

sysbench is a scriptable multi-threaded benchmark tool based on LuaJIT. It is most frequently used for database benchmarks, but can also be used to create arbitrarily complex workloads that do not involve a database server.

Install Sysbench on Raspberry Pi

sudo apt-get install sysbench

Run a basic CPU stress test

To run a basic CPU stress test using sysbench, use the following command:

sysbench --test=cpu --cpu-max-prime=20000 --validate run

This is what I saw on a Raspberry Pi 4

user@raspberrypi:~ $ sysbench --test=cpu --cpu-max-prime=20000 --validate run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Validation checks: on.

Initializing random number generator from current time


Prime numbers limit: 20000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:   580.36

General statistics:
    total time:                          10.0015s
    total number of events:              5807

Latency (ms):
         min:                                    1.71
         avg:                                    1.72
         max:                                    5.74
         95th percentile:                        1.73
         sum:                                 9997.60

Threads fairness:
    events (avg/stddev):           5807.0000/0.00
    execution time (avg/stddev):   9.9976/0.00

More examples

calculate primes

sysbench --test=cpu --cpu-max-prime=20000 run

test the I/O Output of your Raspberry Pi

sysbench --test=fileio --file-total-size=2G prepare
sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run
sysbench --test=fileio --file-total-size=2G cleanup

memory read and write

sysbench --test=memory run --memory-total-size=2G
sysbench --test=memory run --memory-total-size=2G --memory-oper=read

There are many options available

General Command Line Options

The table below lists the supported common options, their descriptions and default values:

Option Description Default value
--threads The total number of worker threads to create 1
--events Limit for total number of requests. 0 (the default) means no limit 0
--time Limit for total execution time in seconds. 0 means no limit 10
--warmup-time Execute events for this many seconds with statistics disabled before the actual benchmark run with statistics enabled. This is useful when you want to exclude the initial period of a benchmark run from statistics. In many benchmarks, the initial period is not representative because CPU/database/page and other caches need some time to warm up 0
--rate Average transactions rate. The number specifies how many events (transactions) per seconds should be executed by all threads on average. 0 (default) means unlimited rate, i.e. events are executed as fast as possible 0
--thread-init-timeout Wait time in seconds for worker threads to initialize 30
--thread-stack-size Size of stack for each thread 32K
--report-interval Periodically report intermediate statistics with a specified interval in seconds. Note that statistics produced by this option is per-interval rather than cumulative. 0 disables intermediate reports 0
--debug Print more debug info off
--validate Perform validation of test results where possible off
--help Print help on general syntax or on a specified test, and exit off
--verbosity Verbosity level (0 – only critical messages, 5 – debug) 4
--percentile sysbench measures execution times for all processed requests to display statistical information like minimal, average and maximum execution time. For most benchmarks it is also useful to know a request execution time value matching some percentile (e.g. 95% percentile means we should drop 5% of the most long requests and choose the maximal value from the remaining ones). This option allows to specify a percentile rank of query execution times to count 95
--luajit-cmd perform a LuaJIT control command. This option is equivalent to luajit -j. See LuaJIT documentation for more information

Note that numerical values for all size options (like --thread-stack-size in this table) may be specified by appending the corresponding multiplicative suffix (K for kilobytes, M for megabytes, G for gigabytes and T for terabytes).

Random Numbers Options

sysbench provides a number of algorithms to generate random numbers that are distributed according to a given probability distribution. The table below lists options that can be used to control those algorithms.

Option Description Default value
--rand-type random numbers distribution {uniform, gaussian, special, pareto, zipfian} to use by default. Benchmark scripts may choose to use either the default distribution, or specify it explictly, i.e. override the default. special
--rand-seed seed for random number generator. When 0, the current time is used as an RNG seed. 0
--rand-spec-iter number of iterations for the special distribution 12
--rand-spec-pct percentage of the entire range where ‘special’ values will fall in the special distribution 1
--rand-spec-res percentage of ‘special’ values to use for the special distribution 75
--rand-pareto-h shape parameter for the Pareto distribution 0.2
--rand-zipfian-exp shape parameter (theta) for the Zipfian distribution 0.8

 

Links

https://github.com/akopytov/sysbench

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More