3v4l.org

run code in 300+ PHP versions simultaneously
<?php session_start(); $classes = get_declared_classes(); $methods = array('get_class_methods' => array(), 'ReflectionClass' => array()); $before = microtime(true); foreach($classes as $class) { $methods['get_class_methods'][$class][] = get_class_methods($class); } $after = ( microtime(true) - $before); @$_SESSION['get_class_methods'][] = $after; $result = array_sum($_SESSION['get_class_methods']) / count(array_filter($_SESSION['get_class_methods'])); echo '<h1>'; echo "get_class_methods: " . number_format($result, 4) . " Seconds"; echo '</h1>'; $before = microtime(true); foreach($classes as $class) { $reflection = new ReflectionClass ( $class ); foreach($reflection->getMethods() as $method) { $methods['ReflectionClass'][$class][] = $method->name; } } $after = ( microtime(true) - $before); @$_SESSION['ReflectionClass'][] = $after; $results = array('get_class_methods' => $result); $result = array_sum($_SESSION['ReflectionClass']) / count(array_filter($_SESSION['ReflectionClass'])); $results['ReflectionClass'] = $result; echo '<h1>'; echo "ReflectionClass: " . number_format($result, 4) . " Seconds"; echo '</h1>'; asort($results); echo '<h1>'; echo key($results)." is " . round(next($results)/prev($results)) . "x faster than "; next($results); echo key($results); echo '</h1>';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 59, Position 2 = 76
Branch analysis from position: 59
2 jumps found. (Code = 78) Position 1 = 60, Position 2 = 76
Branch analysis from position: 60
2 jumps found. (Code = 77) Position 1 = 67, Position 2 = 74
Branch analysis from position: 67
2 jumps found. (Code = 78) Position 1 = 68, Position 2 = 74
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 74
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
Branch analysis from position: 20
filename:       /in/57pnv
function name:  (null)
number of ops:  144
compiled vars:  !0 = $classes, !1 = $methods, !2 = $before, !3 = $class, !4 = $after, !5 = $result, !6 = $reflection, !7 = $method, !8 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'session_start'
          1        DO_ICALL                                                 
    3     2        INIT_FCALL                                               'get_declared_classes'
          3        DO_ICALL                                         $10     
          4        ASSIGN                                                   !0, $10
    4     5        ASSIGN                                                   !1, <array>
    6     6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $13     
          9        ASSIGN                                                   !2, $13
    7    10      > FE_RESET_R                                       $15     !0, ->20
         11    > > FE_FETCH_R                                               $15, !3, ->20
    9    12    >   INIT_FCALL                                               'get_class_methods'
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                         $19     
         15        FETCH_DIM_W                                      $16     !1, 'get_class_methods'
         16        FETCH_DIM_W                                      $17     $16, !3
         17        ASSIGN_DIM                                               $17
         18        OP_DATA                                                  $19
    7    19      > JMP                                                      ->11
         20    >   FE_FREE                                                  $15
   11    21        INIT_FCALL                                               'microtime'
         22        SEND_VAL                                                 <true>
         23        DO_ICALL                                         $20     
         24        SUB                                              ~21     $20, !2
         25        ASSIGN                                                   !4, ~21
   12    26        BEGIN_SILENCE                                    ~23     
         27        FETCH_W                      global              $24     '_SESSION'
         28        FETCH_DIM_W                                      $25     $24, 'get_class_methods'
         29        ASSIGN_DIM                                               $25
         30        OP_DATA                                                  !4
         31        END_SILENCE                                              ~23
   13    32        INIT_FCALL                                               'array_sum'
         33        FETCH_R                      global              ~27     '_SESSION'
         34        FETCH_DIM_R                                      ~28     ~27, 'get_class_methods'
         35        SEND_VAL                                                 ~28
         36        DO_ICALL                                         $29     
         37        INIT_FCALL                                               'array_filter'
         38        FETCH_R                      global              ~30     '_SESSION'
         39        FETCH_DIM_R                                      ~31     ~30, 'get_class_methods'
         40        SEND_VAL                                                 ~31
         41        DO_ICALL                                         $32     
         42        COUNT                                            ~33     $32
         43        DIV                                              ~34     $29, ~33
         44        ASSIGN                                                   !5, ~34
   14    45        ECHO                                                     '%3Ch1%3E'
   15    46        INIT_FCALL                                               'number_format'
         47        SEND_VAR                                                 !5
         48        SEND_VAL                                                 4
         49        DO_ICALL                                         $36     
         50        CONCAT                                           ~37     'get_class_methods%3A+', $36
         51        CONCAT                                           ~38     ~37, '+Seconds'
         52        ECHO                                                     ~38
   16    53        ECHO                                                     '%3C%2Fh1%3E'
   19    54        INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $39     
         57        ASSIGN                                                   !2, $39
   20    58      > FE_RESET_R                                       $41     !0, ->76
         59    > > FE_FETCH_R                                               $41, !3, ->76
   22    60    >   NEW                                              $42     'ReflectionClass'
         61        SEND_VAR_EX                                              !3
         62        DO_FCALL                                      0          
         63        ASSIGN                                                   !6, $42
   23    64        INIT_METHOD_CALL                                         !6, 'getMethods'
         65        DO_FCALL                                      0  $45     
         66      > FE_RESET_R                                       $46     $45, ->74
         67    > > FE_FETCH_R                                               $46, !7, ->74
   25    68    >   FETCH_OBJ_R                                      ~50     !7, 'name'
         69        FETCH_DIM_W                                      $47     !1, 'ReflectionClass'
         70        FETCH_DIM_W                                      $48     $47, !3
         71        ASSIGN_DIM                                               $48
         72        OP_DATA                                                  ~50
   23    73      > JMP                                                      ->67
         74    >   FE_FREE                                                  $46
   20    75      > JMP                                                      ->59
         76    >   FE_FREE                                                  $41
   28    77        INIT_FCALL                                               'microtime'
         78        SEND_VAL                                                 <true>
         79        DO_ICALL                                         $51     
         80        SUB                                              ~52     $51, !2
         81        ASSIGN                                                   !4, ~52
   29    82        BEGIN_SILENCE                                    ~54     
         83        FETCH_W                      global              $55     '_SESSION'
         84        FETCH_DIM_W                                      $56     $55, 'ReflectionClass'
         85        ASSIGN_DIM                                               $56
         86        OP_DATA                                                  !4
         87        END_SILENCE                                              ~54
   30    88        INIT_ARRAY                                       ~58     !5, 'get_class_methods'
         89        ASSIGN                                                   !8, ~58
   31    90        INIT_FCALL                                               'array_sum'
         91        FETCH_R                      global              ~60     '_SESSION'
         92        FETCH_DIM_R                                      ~61     ~60, 'ReflectionClass'
         93        SEND_VAL                                                 ~61
         94        DO_ICALL                                         $62     
         95        INIT_FCALL                                               'array_filter'
         96        FETCH_R                      global              ~63     '_SESSION'
         97        FETCH_DIM_R                                      ~64     ~63, 'ReflectionClass'
         98        SEND_VAL                                                 ~64
         99        DO_ICALL                                         $65     
        100        COUNT                                            ~66     $65
        101        DIV                                              ~67     $62, ~66
        102        ASSIGN                                                   !5, ~67
   32   103        ASSIGN_DIM                                               !8, 'ReflectionClass'
        104        OP_DATA                                                  !5
   33   105        ECHO                                                     '%3Ch1%3E'
   34   106        INIT_FCALL                                               'number_format'
        107        SEND_VAR                                                 !5
        108        SEND_VAL                                                 4
        109        DO_ICALL                                         $70     
        110        CONCAT                                           ~71     'ReflectionClass%3A+', $70
        111        CONCAT                                           ~72     ~71, '+Seconds'
        112        ECHO                                                     ~72
   35   113        ECHO                                                     '%3C%2Fh1%3E'
   37   114        INIT_FCALL                                               'asort'
        115        SEND_REF                                                 !8
        116        DO_ICALL                                                 
   38   117        ECHO                                                     '%3Ch1%3E'
   39   118        INIT_FCALL                                               'key'
        119        SEND_VAR                                                 !8
        120        DO_ICALL                                         $74     
        121        CONCAT                                           ~75     $74, '+is+'
        122        INIT_FCALL                                               'round'
        123        INIT_FCALL                                               'next'
        124        SEND_REF                                                 !8
        125        DO_ICALL                                         $76     
        126        INIT_FCALL                                               'prev'
        127        SEND_REF                                                 !8
        128        DO_ICALL                                         $77     
        129        DIV                                              ~78     $76, $77
        130        SEND_VAL                                                 ~78
        131        DO_ICALL                                         $79     
        132        CONCAT                                           ~80     ~75, $79
        133        CONCAT                                           ~81     ~80, 'x+faster+than+'
        134        ECHO                                                     ~81
   40   135        INIT_FCALL                                               'next'
        136        SEND_REF                                                 !8
        137        DO_ICALL                                                 
   41   138        INIT_FCALL                                               'key'
        139        SEND_VAR                                                 !8
        140        DO_ICALL                                         $83     
        141        ECHO                                                     $83
   42   142        ECHO                                                     '%3C%2Fh1%3E'
        143      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.11 ms | 1408 KiB | 37 Q