diff options
author | David Mitchell <davem@iabyn.com> | 2017-07-08 14:17:15 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-07-27 11:30:22 +0100 |
commit | 775f2c0793edf33325b9ef09b476245658cfd66b (patch) | |
tree | 52bced8249bda865cd121cd01537f321e146c24d | |
parent | 1a436fbe3c7e36cfac949d9e21c6191cb2a33362 (diff) | |
download | perl-775f2c0793edf33325b9ef09b476245658cfd66b.tar.gz |
add some SvTRUE() benchmarks
Add a few not (!) expressions which exercise SvTRUE() for various types
of operand.
-rw-r--r-- | t/perf/benchmarks | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/t/perf/benchmarks b/t/perf/benchmarks index 7e547e6c33..d09f51b401 100644 --- a/t/perf/benchmarks +++ b/t/perf/benchmarks @@ -306,6 +306,11 @@ setup => 'my %h;', code => '!%h', }, + 'expr::hash::bool_empty_unknown' => { + desc => 'empty lexical hash in unknown context', + setup => 'my ($i, %h); sub f { if (%h) { $i++ }}', + code => 'f()', + }, 'expr::hash::bool_full' => { desc => 'non-empty lexical hash in boolean context', setup => 'my %h = 1..10;', @@ -939,6 +944,54 @@ code => '$z = $x * $y', }, + # use '!' to test SvTRUE on various classes of value + + 'expr::arith::not_PL_undef' => { + desc => '!undef (using PL_sv_undef)', + setup => 'my $x', + code => '$x = !undef', + }, + 'expr::arith::not_PL_no' => { + desc => '!($x == $y) (using PL_sv_no)', + setup => 'my ($x, $y) = (1,2); my $z;', + code => '$z = !($x == $y)', + }, + 'expr::arith::not_PL_zero' => { + desc => '!%h (using PL_sv_zero)', + setup => 'my ($x, %h)', + code => '$x = !%h', + }, + 'expr::arith::not_PL_yes' => { + desc => '!($x == $y) (using PL_sv_yes)', + setup => 'my ($x, $y) = (1,1); my $z;', + code => '$z = !($x == $y)', + }, + 'expr::arith::not_undef' => { + desc => '!$y where $y is undef', + setup => 'my ($x, $y)', + code => '$x = !$y', + }, + 'expr::arith::not_0' => { + desc => '!$x where $x is 0', + setup => 'my ($x, $y) = (0, 0)', + code => '$y = !$x', + }, + 'expr::arith::not_1' => { + desc => '!$x where $x is 1', + setup => 'my ($x, $y) = (1, 0)', + code => '$y = !$x', + }, + 'expr::arith::not_string' => { + desc => '!$x where $x is "foo"', + setup => 'my ($x, $y) = ("foo", 0)', + code => '$y = !$x', + }, + 'expr::arith::not_ref' => { + desc => '!$x where $s is an array ref', + setup => 'my ($x, $y) = ([], 0)', + code => '$y = !$x', + }, + 'expr::arith::preinc' => { desc => '++$x', setup => 'my $x = 1;', |