Linux系统下,可以用计算π的方法来简单评估CPU单核计算性能。 # 一、方法 ```bash [root@yz219 ~]# time echo "scale=5000; 4*a(1)" | bc -l -q 3.141592653589793238462643383279502884197169399375105820974944592307\ 81640628620899862803482534211706798214808651328230664709384460955058\ 22317253594081284811174502841027019385211055596446229489549303819644\ …… real 0m20.190s user 0m20.126s sys 0m0.082s ``` 注:scale表示要计算到小数点后多少位。 ## 1.1 MATH LIBRARY If bc is invoked with the -l option, a math library is preloaded and the default scale is set to 20. The math functions will calculate their results to the scale set at the time of their call. The math library defines the following functions: - s(x) The sine of x, x is in radians. 正玄函数 - c(x) The cosine of x, x is in radians. 余玄函数 - a(x) The arctangent of x, arctangent returns radians. 反正切函数 - l(x) The natural logarithm of x. log函数(以2为底) - e(x) The exponential function of raising e to the value x. e的指数函数 - j(n,x) The bessel function of integer order n of x. 贝塞尔函数 # 二、参考 - [计算圆周率](https://blog.csdn.net/zhuying_linux/article/details/7298465) - [linux 测试cpu计算圆周率_linux下的CPU、内存、IO、网络的压力测试](https://blog.csdn.net/weixin_42502957/article/details/111972568) - [Super PI](http://www.superpi.net/)