2013年9月21日土曜日

Linux/CPU負荷 わざと負荷をかける

●CPU
[root@server01 ~]
# chmod 755 cpubusy.pl 
[root@server01 ~]
# ./cpubusy.pl & 

#!/usr/bin/perl 
# cpubusy.pl

$goal = 1000000; 

while (1) { 
$before = time(); 
for ($i = 0; $i < $goal; $i ++) { 
$x = 0.000001; 
$y = sin($x); 
$y = $y + 0.00001; 
}
$y += 0.01; 

# print "One million sin: ", time() - $before, " seconds!\n"; 
}