- 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.
- 影視后期制作(Avid Media Composer 5.0)
- Visual C# 2008開發技術實例詳解
- 機器人智能運動規劃技術
- ROS機器人編程與SLAM算法解析指南
- 讓每張照片都成為佳作的Photoshop后期技法
- RPA(機器人流程自動化)快速入門:基于Blue Prism
- 3D Printing for Architects with MakerBot
- 網絡安全與防護
- 悟透AutoCAD 2009案例自學手冊
- 嵌入式Linux系統實用開發
- 中國戰略性新興產業研究與發展·數控系統
- Microsoft System Center Data Protection Manager Cookbook
- Learning Couchbase
- 玩轉機器人:基于Proteus的電路原理仿真(移動視頻版)
- 白話機器學習算法