diff --git a/src/parallel b/src/parallel index 0a3c9aa1..11755388 100755 --- a/src/parallel +++ b/src/parallel @@ -498,6 +498,7 @@ sub options_hash { "basenameextensionreplace|bner=s" => \$opt::basenameextensionreplace, "seqreplace=s" => \$opt::seqreplace, "jobs|j=s" => \$opt::P, + "delay=f" => \$opt::delay, "load=s" => \$opt::load, "noswap" => \$opt::noswap, "max-line-length-allowed" => \$opt::max_line_length_allowed, @@ -613,7 +614,7 @@ sub get_options_from_array { sub parse_options { # Returns: N/A # Defaults: - $Global::version = 20121126; + $Global::version = 20121127; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; @@ -3906,6 +3907,9 @@ sub start { $job->set_timeout($opt::timeout); $Global::timeoutq->insert($job); } + if($opt::delay) { + ::usleep($opt::delay*1000); + } return $job; } else { # No more processes diff --git a/src/parallel.pod b/src/parallel.pod index cf4323b4..e97cf2d1 100644 --- a/src/parallel.pod +++ b/src/parallel.pod @@ -426,6 +426,13 @@ occurs as a line of input, the rest of the input is ignored. If neither B<-E> nor B<-e> is used, no end of file string is used. +=item B<--delay> I (alpha testing) + +Delay starting next job I seconds. GNU B will pause +I seconds after starting each job. I can be less than 1 +seconds. + + =item B<--dry-run> Print the job to run on stdout (standard output), but do not run the diff --git a/src/parallel.texi b/src/parallel.texi index 72b1d4a3..9e32c87e 100644 --- a/src/parallel.texi +++ b/src/parallel.texi @@ -1086,7 +1086,7 @@ will generate the files: and @verbatim - parallel --results foo/bar echo {1} {2} ::: 1 2 ::: 3 4 + parallel --results foo/bar echo {1} {2} ::: I II ::: III IIII @end verbatim will generate the files: diff --git a/testsuite/tests-to-run/parallel-local164.sh b/testsuite/tests-to-run/parallel-local164.sh index 294a8fc6..66865474 100644 --- a/testsuite/tests-to-run/parallel-local164.sh +++ b/testsuite/tests-to-run/parallel-local164.sh @@ -5,6 +5,9 @@ SERVER2=parallel-server2 # -L1 will join lines ending in ' ' cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | parallel -j10 -k -L1 +echo "### Test --delay" +seq 9 | /usr/bin/time -f %e parallel -j3 --delay 0.3 true {} 2>&1 | perl -pe 's/.[0-9]+$//' + echo '### Test -k 5'; sleep 5 @@ -35,6 +38,6 @@ seq 1 10 | parallel -j 2 echo | sort seq 1 10 | parallel -j 3 echo | sort echo "bug #37694: Empty string argument skipped when using --quote" -parallel -q --nonall perl -le 'print scalar @ARGV' 'a' 'b' '' +parallel -q --nonall perl -le 'print scalar @ARGV' 'a' 'b' '' EOF diff --git a/testsuite/wanted-results/parallel-local164 b/testsuite/wanted-results/parallel-local164 index 04124c76..f9fae32d 100644 --- a/testsuite/wanted-results/parallel-local164 +++ b/testsuite/wanted-results/parallel-local164 @@ -1,3 +1,5 @@ +### Test --delay +3 ### Test -k 5 ### Test -k 3 ### Test -k 4