What are common pitfalls or gotchas with benchmarking (Benchmark module)?

Benchmarking in Perl using the Benchmark module can be tricky. It's important to be aware of common pitfalls like measuring the wrong things, not accounting for variation, and misunderstanding the results. Here's a breakdown of some common gotchas and how to avoid them.
Benchmarking, Perl, Benchmark module, pitfalls, gotchas, code performance, measurement

# Example of using the Benchmark module
use Benchmark qw(cmpthese);

my $n = 1_000_000;

my $result = cmpthese(-1 => {
    'Loop' => sub { for (1..$n) { ; } },
    'Map' => sub { [map {$_} 1..$n]; },
});

print $result;
    

Benchmarking Perl Benchmark module pitfalls gotchas code performance measurement