create processes to benchmark ptql stuff

This commit is contained in:
Doug MacEachern 2005-03-30 18:56:38 +00:00
parent 15053e98ac
commit 06485cbf6b
1 changed files with 27 additions and 0 deletions

27
exp/fork.pl Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/perl
use strict;
#create processes to benchmark ptql stuff
my $num = shift || 10;
my @kids;
my $pid;
for (my $i=0; $i<$num; $i++) {
if (!defined($pid = fork())) {
die "cannot fork: $!";
}
elsif ($pid) {
#parent
push @kids, $pid;
}
else {
#child
sleep 10 while 1;
}
}
for $pid (@kids) {
waitpid($pid, 0);
}