3v4l.org

run code in 300+ PHP versions simultaneously
<?php function benchmark($function, $args=null, $count=1) { $time = microtime(1); for($i=0; $i<$count; $i++) { $result = is_array($args)? call_user_func_array($function, $args): call_user_func_array($function); } return array( 'total_time' => microtime(1) - $time, 'average_time' => (microtime(1) - $time)/$count, 'count' => $count ); } function p($string) { print_r($string . "<br>"); } var_dump(benchmark('p', array('test',1E4))); gc_collect_cycles(); //var_dump(benchmark('p', array('test',1E3)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mkkJt
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'benchmark'
          2        SEND_VAL                                                 'p'
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   23     7        INIT_FCALL                                               'gc_collect_cycles'
          8        DO_ICALL                                                 
   24     9      > RETURN                                                   1

Function benchmark:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 9
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 9
Branch analysis from position: 25
Branch analysis from position: 9
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 9
Branch analysis from position: 25
Branch analysis from position: 9
filename:       /in/mkkJt
function name:  benchmark
number of ops:  39
compiled vars:  !0 = $function, !1 = $args, !2 = $count, !3 = $time, !4 = $i, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      1
    4     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 1
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !3, $6
    5     7        ASSIGN                                                   !4, 0
          8      > JMP                                                      ->23
    7     9    >   TYPE_CHECK                                  128          !1
         10      > JMPZ                                                     ~9, ->17
    8    11    >   INIT_USER_CALL                                0          'call_user_func_array', !0
         12        SEND_ARRAY                                               !1
         13        CHECK_UNDEF_ARGS                                         
         14        DO_FCALL                                      0  $10     
         15        QM_ASSIGN                                        ~11     $10
         16      > JMP                                                      ->21
    9    17    >   INIT_FCALL                                               'call_user_func_array'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $12     
         20        QM_ASSIGN                                        ~11     $12
    7    21    >   ASSIGN                                                   !5, ~11
    5    22        PRE_INC                                                  !4
         23    >   IS_SMALLER                                               !4, !2
         24      > JMPNZ                                                    ~15, ->9
   12    25    >   INIT_FCALL                                               'microtime'
         26        SEND_VAL                                                 1
         27        DO_ICALL                                         $16     
         28        SUB                                              ~17     $16, !3
         29        INIT_ARRAY                                       ~18     ~17, 'total_time'
   13    30        INIT_FCALL                                               'microtime'
         31        SEND_VAL                                                 1
         32        DO_ICALL                                         $19     
         33        SUB                                              ~20     $19, !3
         34        DIV                                              ~21     ~20, !2
         35        ADD_ARRAY_ELEMENT                                ~18     ~21, 'average_time'
   14    36        ADD_ARRAY_ELEMENT                                ~18     !2, 'count'
         37      > RETURN                                                   ~18
   16    38*     > RETURN                                                   null

End of function benchmark

Function p:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mkkJt
function name:  p
number of ops:  6
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        INIT_FCALL                                               'print_r'
          2        CONCAT                                           ~1      !0, '%3Cbr%3E'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                                 
   20     5      > RETURN                                                   null

End of function p

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.18 ms | 1403 KiB | 24 Q