3v4l.org

run code in 300+ PHP versions simultaneously
<?php // more info here: http://ro.php.net/manual/en/function.microtime.php // and here: http://stackoverflow.com/questions/19973037/benchmark-memory-usage-in-php // and an example here: http://3v4l.org/0ifv8 function benchmark(callable $function, $args=null, $count=1) { $time = microtime(TRUE); 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(TRUE) - $time, 'average_time' => (microtime(TRUE) - $time)/$count, 'count' => $count ); } function p($string) { print_r($string . "<br>"); } print( benchmark( p('t1'), array('test', 10) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5NLYu
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'benchmark'
          1        INIT_FCALL                                               'p'
          2        SEND_VAL                                                 't1'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        SEND_VAL                                                 <array>
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
          8      > 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/5NLYu
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
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      1
    8     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !3, $6
    9     7        ASSIGN                                                   !4, 0
          8      > JMP                                                      ->23
   11     9    >   TYPE_CHECK                                  128          !1
         10      > JMPZ                                                     ~9, ->17
   12    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
   13    17    >   INIT_FCALL                                               'call_user_func_array'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $12     
         20        QM_ASSIGN                                        ~11     $12
   11    21    >   ASSIGN                                                   !5, ~11
    9    22        PRE_INC                                                  !4
         23    >   IS_SMALLER                                               !4, !2
         24      > JMPNZ                                                    ~15, ->9
   16    25    >   INIT_FCALL                                               'microtime'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $16     
         28        SUB                                              ~17     $16, !3
         29        INIT_ARRAY                                       ~18     ~17, 'total_time'
   17    30        INIT_FCALL                                               'microtime'
         31        SEND_VAL                                                 <true>
         32        DO_ICALL                                         $19     
         33        SUB                                              ~20     $19, !3
         34        DIV                                              ~21     ~20, !2
         35        ADD_ARRAY_ELEMENT                                ~18     ~21, 'average_time'
   18    36        ADD_ARRAY_ELEMENT                                ~18     !2, 'count'
         37      > RETURN                                                   ~18
   20    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/5NLYu
function name:  p
number of ops:  6
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        INIT_FCALL                                               'print_r'
          2        CONCAT                                           ~1      !0, '%3Cbr%3E'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                                 
   25     5      > RETURN                                                   null

End of function p

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.5 ms | 1403 KiB | 21 Q