Monday, October 31, 2016

cpu benchmarking on linux with sysbench

TL;DR

install synaptic package
$ sudo apt-get install sysbench

run
$ sysbench --num-threads=1 --test=cpu --cpu-max-prime=25000 run


from the man page @ http://man.cx/sysbench(1)
DESCRIPTION

SysBench is a modular, cross−platform and multi−threaded benchmark tool for evaluating OS parameters that are important for a system running a database under intensive load.

The idea of this benchmark suite is to quickly get an impression about system performance without setting up complex database benchmarks or even without installing a database at all.

Current features allow to test the following system parameters:

• file I/O performance
• scheduler performance
• memory allocation and transfer speed
• POSIX threads implementation performance
• database server performance

The design is very simple. SysBench runs a specified number of threads and they all execute requests in parallel. The actual workload produced by requests depends on the specified test mode. You can limit either the total number of requests or the total time for the benchmark, or both.

Available test modes are implemented by compiled−in modules, and SysBench was designed to make adding new test modes an easy task. Each test mode may have additional (or workload−specific) options.

...

TEST MODEs

CPU

The cpu is one of the most simple benchmarks in SysBench. In this mode each request consists in calculation of prime numbers up to a value specified by the −−cpu−max−primes option. All calculations are performed using 64−bit integers.

Each thread executes the requests concurrently until either the total number of requests or the total execution time exceed the limits specified with the common command line options.

Example:
$ sysbench --test=cpu run

--- --- --- --- --- ---

sample output - Lenovo IdeaPad 300:

dog@cat:~$ sysbench --num-threads=4 --test=cpu --cpu-max-prime=25000 run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 4

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 25000

Test execution summary:
    total time:                          12.2696s
    total number of events:              10000
    total time taken by event execution: 49.0625
    per-request statistics:
         min:                                  4.22ms
         avg:                                  4.91ms
         max:                                 34.80ms
         approx.  95 percentile:               5.20ms

Threads fairness:
    events (avg/stddev):           2500.0000/28.85
    execution time (avg/stddev):   12.2656/0.00