- PostgreSQL High Performance Cookbook
- Chitij Chauhan Dinesh Kumar
- 462字
- 2021-07-09 18:47:18
CPU benchmarking
In this recipe, let's discuss how to benchmark the CPU speed using various open source benchmarking tools.
Getting ready
One of the ways to benchmark CPU power is by measuring the wall clock time for the submitted task. The task can be like calculating the factorial of the given number, or calculating the nth Fibonacci number, or some other CPU-intensive task.
How to do it...
Let us discuss about how to configure phoronix and sysbench tools to benchmark the CPU:
Phoronix
Phoronix supports a set of CPU tests in a test suite called CPU. This test suite covers multiple CPU-intensive tasks, which are mentioned at the following URL: https://openbenchmarking.org/suite/pts/CPU.
If you want to run this CPU test suite, then you need to execute the Phoronix Test Suite benchmark CPU command as a root user. We can also run a specific test by mentioning its test name. For example, let's run a sample CPU benchmarking test as follows:
$ phoronix-test-suite benchmark pts/himeno Phoronix Test Suite v6.8.0 To Install: pts/himeno-1.2.0 ... 1 Test To Install pts/himeno-1.2.0: Test Installation 1 of 1 1 File Needed Downloading: himenobmtxpa.tar.bz2 Started Run 2 @ 05:53:40 Started Run 3 @ 05:54:35 [Std. Dev: 1.66%] Test Results: 1503.636072 1512.166077 1550.985494 Average: 1522.26 MFLOPS
Phoronix also provides a way to observe the detailed test results via HTML file. Also, it supports the offline generation of PDF, JSON, CSV, and text format outputs. To open these test results in the browser, we need to execute the following command:
$ phoronix-test-suite show-result <Test Name>
The following is a sample screenshot of the results of the preceding command:

sysbench
The sysbench
tool provides a CPU task, which calculates the number of prime numbers within a given range and provides the CPU-elapsed time. Let's execute the sysbench
command as shown in the following screenshot, to retrieve the CPU measurements:
[root@localhost ~]# sysbench --test=CPU --CPU-max-prime=10000 --num-threads=4 run Doing CPU performance benchmark Threads started! Done. Maximum prime number checked in CPU test: 10000 Test execution summary: total time: 3.2531s total number of events: 10000 total time taken by event execution: 13.0040 per-request statistics: min: 1.10ms avg: 1.30ms max: 8.60ms approx. 95 percentile: 1.43ms Threads fairness: events (avg/stddev): 2500.0000/8.46 execution time (avg/stddev): 3.2510/0.00
How it works...
The preceding results are collected from CentOS 7, which was running virtually on a Windows 10 machine. The virtual machine has four processing units (CPU cores) of Intel Core i7-4510U of CPU family six.
Phoronix
The URL http://openbenchmarking.org/ provides a detailed description of each test detail along with its implementation, and would encourage you to read more information about the himeno test case.
sysbench
From the previous results, the system takes 3.2531 seconds to compute the 10,000 prime numbers, with the help of four background threads.
- ArchiCAD 19:The Definitive Guide
- Microsoft Dynamics CRM Customization Essentials
- 計算機應用
- Practical Ansible 2
- 手把手教你玩轉RPA:基于UiPath和Blue Prism
- 圖形圖像處理(Photoshop)
- 城市道路交通主動控制技術
- Implementing Oracle API Platform Cloud Service
- Splunk Operational Intelligence Cookbook
- 基于單片機的嵌入式工程開發詳解
- 工業機器人應用案例集錦
- 網站前臺設計綜合實訓
- Chef:Powerful Infrastructure Automation
- 機器人人工智能
- 單片機原理實用教程