# Unixbench性能测试工具

[UnixBench](https://github.com/kdlucas/byte-unixbench)始于BYTE UNIX benchmark suite，多年以来由很多人更新和修改，提供了对Unix系统对基本性能度量，用于对比不同系统对性能。

UnixBench测试也包含了一些非常简单对图形测试，并且能够针对多处理器复制足够的副本进行多处理器性能压测。即首先运行一个单任务测试单个CPU性能，然后按照系统的处理器数量调用相应的多任务并发测试。

* 安装

```
yum install gcc gcc-c++ make libXext-devel

wget https://github.com/kdlucas/byte-unixbench/archive/v5.1.3.tar.gz

tar xf v5.1.3.tar.gz
cd byte-unixbench-5.1.3/UnixBench
make
```

> 对于Debian/Ubuntu，则使用如下命令安装依赖编译库软件包：

```
sudo apt-get install libx11-dev libgl1-mesa-dev libxext-dev perl perl-modules make git
```

* 运行

```
./Run
```

如果要测试限制指定cpu数量，例如2个cpu

```
./Run -c 2
```

在ARM系统(128核心)上，执行 `./Run -c 128` 会出现报错:

```
0 CPUs in system; running 128 parallel copies of tests
```

如果只测试部分测试案例，可以以参数传递测试用例：

```
./Run dhry2reg whetstone-double syscall pipe context1 spawn execl shell1 shell8 shell16
```

* 如果要不断循环测试，请参考 [使用nohup执行while循环](https://github.com/huataihuang/cloud-atlas-draft/tree/c8515755d936ed66b7f4712fbff07fb93005e051/develop/shell/bash/nohup_while_loop/README.md)

```bash
nohup sh -c 'while true;do ./Run;done' &
```

## 排错

在CentOS 6.9上编译后执行会提示错误：

```
Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./Run line 6.
BEGIN failed--compilation aborted at ./Run line 6.
```

参考 [Can’t locate Time/HiRes.pm Perl](https://drewsymo.com/2016/05/09/cant-locate-timehires-pm-perl/) 和 [Perl-Can't locate Time/HiRes.pm 错误](http://blog.51cto.com/perlin/1192035):

```
yum install perl-Time-HiRes
```

## 参考

* [Install and Run UnixBench on CentOS or Debian VPS](https://my.vps6.net/knowledgebase/1/Install-and-Run-UnixBench-on-CentOS-or-Debian-VPS.html)
* [How to benchmark a linux server using UnixBench](https://www.copahost.com/blog/benchmark-linux-unixbench/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/performance/utilities/unixbench.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
