perl - generate high cpu / system load

Useful in testing monitoring scripts and performance tools.

#!/usr/bin/perl

use strict;
use Getopt::Long;
 
chomp(my $numcpu = `grep ^processor /proc/cpuinfo | wc -l`);

GetOptions (
    'c|cpu=i'  =>  \$numcpu    # defaults to the number of cpu on the system
);

while (--$numcpu and fork) {
}; 

while () {
}
source

No comments:

Post a Comment