This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_leavesub(): call FREETMPS and optimise
[perl5.git] / t / perf / benchmarks
index 550c797..2a04845 100644 (file)
         setup   => 'sub f { }',
         code    => 'f()',
     },
+    'call::sub::amp_empty' => {
+        desc    => '&foo function call with no args or body',
+        setup   => 'sub f { }; @_ = ();',
+        code    => '&f',
+    },
     'call::sub::args3' => {
         desc    => 'function call with 3 local lexical vars',
         setup   => 'sub f { my ($a, $b, $c) = @_; 1 }',
         code    => 'f(1,2,3)',
     },
+    'call::sub::args2_ret1' => {
+        desc    => 'function call with 2 local lex vars and 1 return value',
+        setup   => 'my $x; sub f { my ($a, $b) = @_; $a+$b }',
+        code    => '$x = f(1,2)',
+    },
+    'call::sub::args2_ret1temp' => {
+        desc    => 'function call with 2 local lex vars and 1 return TEMP value',
+        setup   => 'my $x; sub f { my ($a, $b) = @_; \$a }',
+        code    => '$x = f(1,2)',
+    },
     'call::sub::args3_ret3' => {
         desc    => 'function call with 3 local lex vars and 3 return values',
         setup   => 'my @a; sub f { my ($a, $b, $c) = @_; $a+$b, $c, 1 }',
         code    => '@a = f(1,2,3)',
     },
+    'call::sub::args3_ret3str' => {
+        desc    => 'function call with 3 local lex vars and 3 string return values',
+        setup   => 'my @a; sub f { my ($a, $b, $c) = @_; my @s = ("aa","bb","cc"); @s }',
+        code    => '@a = f(1,2,3)',
+    },
+    'call::sub::args3_ret3temp' => {
+        desc    => 'function call with 3 local lex vars and 3 TEMP return values',
+        setup   => 'my @a; sub f { my ($a, $b, $c) = @_; 1..3 }',
+        code    => '@a = f(1,2,3)',
+    },
+    'call::sub::recursive' => {
+        desc    => 'basic recursive function call',
+        setup   => 'my $x; sub f { my ($i) = @_; $i > 0 ? $i + f($i-1) : 0 }',
+        code    => '$x = f(1)',
+    },
 
     'call::goto::empty' => {
         desc    => 'goto &funtion with no args or body',
     },
 
 
-    'expr::assign::scalar_lex' => {
+    'expr::assign::scalar_lex_int' => {
         desc    => 'lexical $x = 1',
         setup   => 'my $x',
         code    => '$x = 1',
     },
+    'expr::assign::scalar_lex_str' => {
+        desc    => 'lexical $x = "abc"',
+        setup   => 'my $x',
+        code    => '$x = "abc"',
+    },
+    'expr::assign::scalar_lex_strint' => {
+        desc    => 'lexical $x = 1 where $x was previously a string',
+        setup   => 'my $x = "abc"',
+        code    => '$x = 1',
+    },
+    'expr::assign::scalar_lex_intstr' => {
+        desc    => 'lexical $x = "abc" where $x was previously an int',
+        setup   => 'my $x = 1;',
+        code    => '$x = "abc"',
+    },
     'expr::assign::2list_lex' => {
         desc    => 'lexical ($x, $y) = (1, 2)',
         setup   => 'my ($x, $y)',
         code    => '$y = $x--', # scalar context so not optimised to --$x
     },
 
+    'loop::block' => {
+        desc    => 'empty basic loop',
+        setup   => ';',
+        code    => '{1;}',
+    },
+
+    'loop::do' => {
+        desc    => 'basic do block',
+        setup   => 'my $x; my $y = 2;',
+        code    => '$x = do {1; $y}', # the ';' stops the do being optimised
+    },
 
-    'loop::for_my_range' => {
-        desc    => 'empty for loop with my var and integer range',
+    'loop::for::my_range1' => {
+        desc    => 'empty for loop with my var and integer range',
         setup   => '',
-        code    => 'for my $x (1..10) {}',
+        code    => 'for my $x (1..1) {}',
+    },
+    'loop::for::lex_range1' => {
+        desc    => 'empty for loop with lexical var and 1 integer range',
+        setup   => 'my $x;',
+        code    => 'for $x (1..1) {}',
+    },
+    'loop::for::pkg_range1' => {
+        desc    => 'empty for loop with package var and 1 integer range',
+        setup   => '$x = 1;',
+        code    => 'for $x (1..1) {}',
+    },
+    'loop::for::defsv_range1' => {
+        desc    => 'empty for loop with $_ and integer 1 range',
+        setup   => ';',
+        code    => 'for (1..1) {}',
+    },
+    'loop::for::my_range4' => {
+        desc    => 'empty for loop with my var and 4 integer range',
+        setup   => '',
+        code    => 'for my $x (1..4) {}',
+    },
+    'loop::for::lex_range4' => {
+        desc    => 'empty for loop with lexical var and 4 integer range',
+        setup   => 'my $x;',
+        code    => 'for $x (1..4) {}',
+    },
+    'loop::for::pkg_range4' => {
+        desc    => 'empty for loop with package var and 4 integer range',
+        setup   => '$x = 1;',
+        code    => 'for $x (1..4) {}',
+    },
+    'loop::for::defsv_range4' => {
+        desc    => 'empty for loop with $_ and integer 4 range',
+        setup   => ';',
+        code    => 'for (1..4) {}',
+    },
+
+    'loop::for::my_list1' => {
+        desc    => 'empty for loop with my var and 1 integer list',
+        setup   => '',
+        code    => 'for my $x (1) {}',
+    },
+    'loop::for::lex_list1' => {
+        desc    => 'empty for loop with lexical var and 1 integer list',
+        setup   => 'my $x;',
+        code    => 'for $x (1) {}',
+    },
+    'loop::for::pkg_list1' => {
+        desc    => 'empty for loop with package var and 1 integer list',
+        setup   => '$x = 1;',
+        code    => 'for $x (1) {}',
+    },
+    'loop::for::defsv_list1' => {
+        desc    => 'empty for loop with $_ and integer 1 list',
+        setup   => ';',
+        code    => 'for (1) {}',
+    },
+    'loop::for::my_list4' => {
+        desc    => 'empty for loop with my var and 4 integer list',
+        setup   => '',
+        code    => 'for my $x (1,2,3,4) {}',
+    },
+    'loop::for::lex_list4' => {
+        desc    => 'empty for loop with lexical var and 4 integer list',
+        setup   => 'my $x;',
+        code    => 'for $x (1,2,3,4) {}',
+    },
+    'loop::for::pkg_list4' => {
+        desc    => 'empty for loop with package var and 4 integer list',
+        setup   => '$x = 1;',
+        code    => 'for $x (1,2,3,4) {}',
+    },
+    'loop::for::defsv_list4' => {
+        desc    => 'empty for loop with $_ and integer 4 list',
+        setup   => '',
+        code    => 'for (1,2,3,4) {}',
+    },
+
+    'loop::for::my_array1' => {
+        desc    => 'empty for loop with my var and 1 integer array',
+        setup   => 'my @a = (1);',
+        code    => 'for my $x (@a) {}',
+    },
+    'loop::for::lex_array1' => {
+        desc    => 'empty for loop with lexical var and 1 integer array',
+        setup   => 'my $x; my @a = (1);',
+        code    => 'for $x (@a) {}',
+    },
+    'loop::for::pkg_array1' => {
+        desc    => 'empty for loop with package var and 1 integer array',
+        setup   => '$x = 1; my @a = (1);',
+        code    => 'for $x (@a) {}',
+    },
+    'loop::for::defsv_array1' => {
+        desc    => 'empty for loop with $_ and integer 1 array',
+        setup   => 'my @a = (@a);',
+        code    => 'for (1) {}',
+    },
+    'loop::for::my_array4' => {
+        desc    => 'empty for loop with my var and 4 integer array',
+        setup   => 'my @a = (1..4);',
+        code    => 'for my $x (@a) {}',
+    },
+    'loop::for::lex_array4' => {
+        desc    => 'empty for loop with lexical var and 4 integer array',
+        setup   => 'my $x; my @a = (1..4);',
+        code    => 'for $x (@a) {}',
+    },
+    'loop::for::pkg_array4' => {
+        desc    => 'empty for loop with package var and 4 integer array',
+        setup   => '$x = 1; my @a = (1..4);',
+        code    => 'for $x (@a) {}',
+    },
+    'loop::for::defsv_array4' => {
+        desc    => 'empty for loop with $_ and integer 4 array',
+        setup   => 'my @a = (1..4);',
+        code    => 'for (@a) {}',
+    },
+
+    'loop::while::i1' => {
+        desc    => 'empty while loop 1 iteration',
+        setup   => 'my $i = 0;',
+        code    => 'while (++$i % 2) {}',
+    },
+    'loop::while::i4' => {
+        desc    => 'empty while loop 4 iterations',
+        setup   => 'my $i = 0;',
+        code    => 'while (++$i % 4) {}',
     },
 
 ];