Skip to content

Commit e972d38

Browse files
committed
faster fork.t
Reduce the time between starting the 2nd child after the 1st one from 5s to 3s, and remove the unnecessary random & constant sleep at the beginning. The overall sleep time is now 6s, previously the average sleep time was 14s and the worst sleep time 18s.
1 parent 2ab4b4d commit e972d38

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

t/fork.t

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ for my $i (1 .. $children) {
3838
} else {
3939
# in a child we can't keep the count properly so we do it manually
4040
# make sure that child 1 dies first
41-
srand();
42-
my $time = (($i-1) * 5) +int(rand(5));
41+
my $time = ($i-1) * 3;
4342
print "# child $i sleeping for $time seconds\n";
4443
sleep($time);
4544
my $count = $i + 1;
@@ -72,8 +71,7 @@ for my $i (1 .. $children) {
7271
# parent process
7372
next;
7473
} else {
75-
srand();
76-
my $time = (($i-1) * 5) +int(rand(5));
74+
my $time = ($i-1) * 3;
7775
print "# child $i sleeping for $time seconds\n";
7876
sleep($time);
7977
my $count = 5 + $i;

0 commit comments

Comments
 (0)