3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* How many times the code under test should run in each function */ define('LOOP', 10); define('MAX', 10); function f1() { for ($i = 0; $i < LOOP; ++$i) { // one liner array_map with anonymous function - 5.3+ $array = array_map(function($d) { return 'count_' . $d; }, range(0, MAX)); } } function f2() { for ($i = 0; $i < LOOP; ++$i) { // another (convoluted) one line approach, avoiding array_map - 5.2+ $array = explode('#', 'count_' . implode('#count_', range(0, MAX))); } } $start = microtime(true); f1(); $stop = microtime(true); $time1 = $stop - $start; $start = microtime(true); f2(); $stop = microtime(true); $time2 = $stop - $start; echo $time1 . "\t"; echo $time2 . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iK6nC
function name:  (null)
number of ops:  37
compiled vars:  !0 = $start, !1 = $stop, !2 = $time1, !3 = $time2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'LOOP'
          2        SEND_VAL                                                 10
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'define'
          5        SEND_VAL                                                 'MAX'
          6        SEND_VAL                                                 10
          7        DO_ICALL                                                 
   20     8        INIT_FCALL                                               'microtime'
          9        SEND_VAL                                                 <true>
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !0, $6
   21    12        INIT_FCALL                                               'f1'
         13        DO_FCALL                                      0          
   22    14        INIT_FCALL                                               'microtime'
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $9      
         17        ASSIGN                                                   !1, $9
   23    18        SUB                                              ~11     !1, !0
         19        ASSIGN                                                   !2, ~11
   25    20        INIT_FCALL                                               'microtime'
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $13     
         23        ASSIGN                                                   !0, $13
   26    24        INIT_FCALL                                               'f2'
         25        DO_FCALL                                      0          
   27    26        INIT_FCALL                                               'microtime'
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $16     
         29        ASSIGN                                                   !1, $16
   28    30        SUB                                              ~18     !1, !0
         31        ASSIGN                                                   !3, ~18
   30    32        CONCAT                                           ~20     !2, '%09'
         33        ECHO                                                     ~20
   31    34        CONCAT                                           ~21     !3, '%0A'
         35        ECHO                                                     ~21
         36      > RETURN                                                   1

Function f1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 2
Branch analysis from position: 17
Branch analysis from position: 2
filename:       /in/iK6nC
function name:  f1
number of ops:  18
compiled vars:  !0 = $i, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->14
   10     2    >   INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FiK6nC%3A10%240'
          4        SEND_VAL                                                 ~3
          5        INIT_FCALL                                               'range'
          6        SEND_VAL                                                 0
          7        FETCH_CONSTANT                                   ~4      'MAX'
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                         $5      
         10        SEND_VAR                                                 $5
         11        DO_ICALL                                         $6      
         12        ASSIGN                                                   !1, $6
    8    13        PRE_INC                                                  !0
         14    >   FETCH_CONSTANT                                   ~9      'LOOP'
         15        IS_SMALLER                                               !0, ~9
         16      > JMPNZ                                                    ~10, ->2
   12    17    > > RETURN                                                   null

End of function f1

Function %00%7Bclosure%7D%2Fin%2FiK6nC%3A10%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iK6nC
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        CONCAT                                           ~1      'count_', !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FiK6nC%3A10%240

Function f2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 2
Branch analysis from position: 21
Branch analysis from position: 2
filename:       /in/iK6nC
function name:  f2
number of ops:  22
compiled vars:  !0 = $i, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->18
   17     2    >   INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%23'
          4        INIT_FCALL                                               'implode'
          5        SEND_VAL                                                 '%23count_'
          6        INIT_FCALL                                               'range'
          7        SEND_VAL                                                 0
          8        FETCH_CONSTANT                                   ~3      'MAX'
          9        SEND_VAL                                                 ~3
         10        DO_ICALL                                         $4      
         11        SEND_VAR                                                 $4
         12        DO_ICALL                                         $5      
         13        CONCAT                                           ~6      'count_', $5
         14        SEND_VAL                                                 ~6
         15        DO_ICALL                                         $7      
         16        ASSIGN                                                   !1, $7
   15    17        PRE_INC                                                  !0
         18    >   FETCH_CONSTANT                                   ~10     'LOOP'
         19        IS_SMALLER                                               !0, ~10
         20      > JMPNZ                                                    ~11, ->2
   19    21    > > RETURN                                                   null

End of function f2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.52 ms | 1407 KiB | 27 Q