- 论坛徽章:
- 0
|
回复 #2 五“宅”一生 的帖子
在做 CPU 和 内存 的测试, 网上 用 的PERL SCRIPTS
但要 stop by \'ctrl+c\', 不然 死机。 有么没有 办法 CPU 到 90% , 自动 停了?
./buffer_write.pl -size=100000 | ./buffer_read.pl
scripts buffer_write.pl
#!/usr/bin/perl -s
# write to the stdout, but with no \'\\n\' character causes
# the internal (stdio?) buffer to fill up.
# when used with the perl buffered <> operation
#
# use -size=n
#
# to increase the write
$main::size ||= 10_000;
$count;
sub do_write {
$buf = chr int(rand(25)+65);
$message = $buf x $size;
$message .= \"\\n\" if $line;;
print \"$message\"; # no new line !!!
$count += length $message;
warn \"$count bytes\\n\";
}
while (\"stress\" ne \"frozen over\") {
do_write;
}
=============
scripts buffer_read.pl
#!/usr/bin/perl -n
print length($_), \"\\n\";
print; |
|