In the past, CPU cycle speed was the primary indicator of a CPU's performance. However, modern CPUs from various manufacturers now feature different architectures and optimizations, making benchmarks necessary to assess their actual speed.
CPU benchmarking tools execute tasks on the CPUs and measure the time taken for completion. Some tasks are purely synthetic, while others attempt to mimic real-world usage. Regardless, it is impossible for these tasks to fully represent the diverse ways in which individuals utilize CPUs.
Although there are numerous third-party and commercial applications for conducting CPU benchmarks, sysbench is a widely-used, standard tool in Linux systems. It is available in the default package repositories of most Linux distributions.
$ sudo apt update && sudo apt install --assume-yes sysbench #Ubuntu and variants > sudo zypper refresh && sudo zypper install --skip-interactive sysbench $ sudo dnf install sysbench
$ lscpu | grep "^CPU.s\|^Thread.s" CPU(s): 8 Thread(s) per core: 2
$ sysbench cpu run sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3) 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: 8651.52 General statistics: total time: 10.0002s total number of events: 86521 Latency (ms): min: 0.11 avg: 0.12 max: 1.21 95th percentile: 0.12 sum: 9987.69 Threads fairness: events (avg/stddev): 86521.0000/0.00 execution time (avg/stddev): 9.9877/0.00
$ sysbench cpu --threads=16 run sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3) Running the test with following options: Number of threads: 16 Initializing random number generator from current time Prime numbers limit: 10000 Initializing worker threads... Threads started! CPU speed: events per second: 16608.45 General statistics: total time: 10.0006s total number of events: 166101 Latency (ms): min: 0.11 avg: 0.96 max: 68.15 95th percentile: 0.13 sum: 159504.98 Threads fairness: events (avg/stddev): 10381.3125/69.32 execution time (avg/stddev): 9.9691/0.02
$ sysbench cpu --threads=16 --time=60 run sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3) Running the test with following options: Number of threads: 16 Initializing random number generator from current time Prime numbers limit: 10000 Initializing worker threads... Threads started! CPU speed: events per second: 16649.33 General statistics: total time: 60.0007s total number of events: 998978 Latency (ms): min: 0.11 avg: 0.96 max: 101.62 95th percentile: 0.13 sum: 958670.12 Threads fairness: events (avg/stddev): 62436.1250/236.58 execution time (avg/stddev): 59.9169/0.03
Longer benchmarks can cause the CPU to hit and emulate frequency scaling and thermal limitations.
$ sysbench --help Usage: sysbench [options]... [testname] [command] Commands implemented by most tests: prepare run cleanup help General options: --threads=N number of threads to use [1] --events=N limit for total number of events [0] --time=N limit for total execution time in seconds [10] --forced-shutdown=STRING number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off] --thread-stack-size=SIZE size of stack per thread [64K] --rate=N average transactions rate. 0 for unlimited rate [0] --report-interval=N periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0] --report-checkpoints=[LIST,...] dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. [] --debug[=on|off] print more debugging info [off] --validate[=on|off] perform validation checks where possible [off] --help[=on|off] print help and exit [off] --version[=on|off] print version and exit [off] --config-file=FILENAME File containing command line options --tx-rate=N deprecated alias for --rate [0] --max-requests=N deprecated alias for --events [0] --max-time=N deprecated alias for --time [0] --num-threads=N deprecated alias for --threads [1] Pseudo-Random Numbers Generator options: --rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special] --rand-spec-iter=N number of iterations used for numbers generation [12] --rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1] --rand-spec-res=N percentage of 'special' values to use (for special distribution) [75] --rand-seed=N seed for random number generator. When 0, the current time is used as a RNG seed. [0] --rand-pareto-h=N parameter h for pareto distribution [0.2] Log options: --verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3] --percentile=N percentile to calculate in latency statistics (1-100). Use the special value of 0 to disable percentile calculations [95] --histogram[=on|off] print latency histogram in report [off] General database options: --db-driver=STRING specifies database driver to use ('help' to get list of available drivers) [mysql] --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto] --db-debug[=on|off] print database-specific debug information [off] Compiled-in database drivers: mysql - MySQL driver pgsql - PostgreSQL driver mysql options: --mysql-host=[LIST,...] MySQL server host [localhost] --mysql-port=[LIST,...] MySQL server port [3306] --mysql-socket=[LIST,...] MySQL socket --mysql-user=STRING MySQL user [sbtest] --mysql-password=STRING MySQL password [] --mysql-db=STRING MySQL database name [sbtest] --mysql-ssl[=on|off] use SSL connections, if available in the client library [off] --mysql-ssl-cipher=STRING use specific cipher for SSL connections [] --mysql-compression[=on|off] use compression, if available in the client library [off] --mysql-debug[=on|off] trace all client library calls [off] --mysql-ignore-errors=[LIST,...] list of errors to ignore, or "all" [1213,1020,1205] --mysql-dry-run[=on|off] Dry run, pretend that all MySQL client API calls are successful without executing them [off] pgsql options: --pgsql-host=STRING PostgreSQL server host [localhost] --pgsql-port=N PostgreSQL server port [5432] --pgsql-user=STRING PostgreSQL user [sbtest] --pgsql-password=STRING PostgreSQL password [] --pgsql-db=STRING PostgreSQL database name [sbtest] Compiled-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 See 'sysbench <testname> help' for a list of options for each test.
Comment anonymously. Login not required.