#!/usr/bin/perl -w use strict; use Time::HiRes qw(usleep ualarm gettimeofday tv_interval); open (FILE, ">testfork.txt"); my $runs = 33; my $start = [gettimeofday]; while ($runs) { my $pid = fork; # Parent if ($pid) { $runs--; } # Child if ($pid == 0) { my $pid = fork; if ($pid == 0) { my $pid = fork; if ($pid == 0) { print FILE "$runs\n"; exit; } print FILE "$runs\n"; exit; } print FILE "$runs\n"; exit; } } my $elapse = tv_interval ($start); close (FILE); print "Elapsed time = $elapse\n"; exit; #### #!/usr/bin/perl -w use strict; use Time::HiRes qw(usleep ualarm gettimeofday tv_interval); open (FILE, ">testfork.txt"); my $runs = 99; my $start = [gettimeofday]; while ($runs) { my $pid = fork; # Parent if ($pid) { $runs--; } # Child if ($pid == 0) { # my $pid = fork; # if ($pid == 0) { # my $pid = fork; # if ($pid == 0) { # print FILE "$runs\n"; # exit; # } # print FILE "$runs\n"; # exit; # } print FILE "$runs\n"; exit; } } my $elapse = tv_interval ($start); close (FILE); print "Elapsed time = $elapse\n"; exit;