我希望对机器进行压力测试,sysbench
以便我可以获得每秒写入文件的 CPU 温度。现在测试运行超过了我设置的最长时间。如何让它在最大时间后停止?
#!/bin/bash
end=$((SECONDS+30))
echo $(vcgencmd measure_temp | egrep -o '[0-9]*\.[0-9]*') >> ~/research/temperatures.txt
sysbench --test=cpu --cpu-max-prime=2000000 run --max-time=10
while [ $SECONDS -lt $end ]; do
echo $(vcgencmd measure_temp | egrep -o '[0-9]*\.[0-9]*') >> ~/research/temperatures.txt
done
然后测试运行了 20 多秒,并且在 10 秒时没有停止:
$ ./stress-test
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Doing CPU performance benchmark
Threads started!
Time limit exceeded, exiting...
Done.
Maximum prime number checked in CPU test: 2000000
Test execution summary:
total time: 24.7510s
total number of events: 1
total time taken by event execution: 24.7387
per-request statistics:
min: 24738.74ms
avg: 24738.74ms
max: 24738.74ms
approx. 95 percentile: 10000000.00ms
Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 24.7387/0.00
我现在只是将时间设置得很低,以确保测试停止而无需等待我将要测试的完整时间。