Linux系统下,可以用计算π的方法来简单评估CPU单核计算性能。
[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表示要计算到小数点后多少位。
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: