t/perf/benchmarks: tweak mixed arithmetic

The benchmarks which test adding an int to a num weren't measuring
correctly because, after the first iteration, the PVIV var got upgraded
to a PVNV - thus causing the optimised 'both args NV' path to be chosen
after that.

Make the benchmark recreate the integer variable on each iteration
This commit is contained in:
David Mitchell 2020-08-28 10:22:02 +01:00
parent 2a920e30f9
commit 76b30116a0

View File

@ -952,12 +952,14 @@
},
'expr::arith::add_lex_ni' => {
desc => 'add an int and an NV and assign to a lexical var',
setup => 'my ($x,$y,$z) = (1, 2.2, 3.3);',
setup => 'my ($y,$z) = (2.2, 3.3);',
pre => 'my $x = 1', # after 1st iter gets upgraded to PVNV
code => '$z = $x + $y',
},
'expr::arith::add_pkg_ni' => {
desc => 'add an int and an NV and assign to a package var',
setup => 'my ($x,$y); ($x,$y,$z) = (1, 2.2, 3.3);',
setup => 'my ($y); ($y,$z) = (2.2, 3.3);',
pre => 'my $x = 1', # after 1st iter gets upgraded to PVNV
code => '$z = $x + $y',
},
'expr::arith::add_lex_ss' => {