measured time mismatch in running curl in parallel

Viewed 69

I want to measure time taken by individual curl command and also total time taken by set of curl commands running in parallel, However I could see mismatch between these two numbers as follows

time seq 2 | parallel -n0 "curl -o /dev/null -s -w %{time_total}\\n -x http://mywebsite"

I could see following output curl 1- 1.828647 curl 2- 1.894729 total time printed by 'time' real 0m2.034s user 0m0.267s sys 0m0.332s

if I add up curl 1 and curl 2 times is not equal to 'real' time printed by 'time' command. could you explain why they are not same?

1 Answers

Maybe it is easier to understand with a simpler example:

$ time seq 2 | time parallel --tag time sleep
1
1       real    0m1.037s
1       user    0m0.000s
1       sys     0m0.030s
2
2       real    0m2.032s
2       user    0m0.015s
2       sys     0m0.000s

(parallel)
0.24user 0.25system 0:02.59elapsed 19%CPU (0avgtext+0avgdata 233104maxresident)k
0inputs+0outputs (60960major+0minor)pagefaults 0swaps

(seq)
real    0m2.631s
user    0m0.260s
sys     0m0.290s

The total time is > 2s but it is not 3s because sleep 1 and sleep 2 run in parallel.

Related