in reply to Strange behavior with Benchmark
This is because speed computations are done by CPU time, and a program doesn't use any CPU time while sleeping. Moreover, "real" (CPU + "other things") time is computed using time(2) and thus is measured in seconds, not any more precisely.
You can still try to count the real execution time by using timeit and its returned Benchmark object:
use Benchmark; use feature 'say'; say timeit(5, sub { sleep 4 })->real; say timeit(5, sub { sleep 6 })->real;
|
|---|