3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Object hashing tests. */ $sos = new SplObjectStorage(); $usage = "php %s INTEGER \t - Run the SPLObjectStorage vs. Array test with INTEGER size.\n"; if (count($argv) < 2) { printf($usage, $argv[0]); exit(1); } $docs = array(); $iterations = (int)$argv[1]; //100000; for ($i = 0; $i < $iterations; ++$i) { $doc = new DOMDocument(); //$doc = new stdClass(); $docs[] = $doc; } $start = $finis = 0; $mem_empty = memory_get_usage(); // Load the SplObjectStorage $start = microtime(TRUE); foreach ($docs as $d) { $sos->attach($d); } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the object storage $start = microtime(FALSE); foreach ($docs as $d) { $sos->contains($d); } $finis = microtime(FALSE); $time_to_check = $finis - $start; $mem_spl = memory_get_usage(); $mem_used = $mem_spl - $mem_empty; printf("SplObjectStorage:\nTime to fill: %0.12f.\nTime to check: %0.12f.\nMemory: %d\n\n", $time_to_fill, $time_to_check, $mem_used); unset($sos); $mem_empty = memory_get_usage(); // Test arrays: $start = microtime(TRUE); $arr = array(); // Load the array foreach ($docs as $d) { $arr[spl_object_hash($d)] = $d; } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the array $start = microtime(FALSE); foreach ($docs as $d) { //$arr[spl_object_hash($d)]; isset($arr[spl_object_hash($d)]); } $finis = microtime(FALSE); $time_to_check = $finis - $start; $mem_arr = memory_get_usage(); $mem_used = $mem_arr - $mem_empty; printf("Arrays:\nTime to fill: %0.12f.\nTime to check: %0.12f.\nMemory: %d\n\n", $time_to_fill, $time_to_check, $mem_used);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 19
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 42
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 42
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 42
2 jumps found. (Code = 77) Position 1 = 54, Position 2 = 59
Branch analysis from position: 54
2 jumps found. (Code = 78) Position 1 = 55, Position 2 = 59
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 59
2 jumps found. (Code = 77) Position 1 = 87, Position 2 = 94
Branch analysis from position: 87
2 jumps found. (Code = 78) Position 1 = 88, Position 2 = 94
Branch analysis from position: 88
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
Branch analysis from position: 94
2 jumps found. (Code = 77) Position 1 = 106, Position 2 = 113
Branch analysis from position: 106
2 jumps found. (Code = 78) Position 1 = 107, Position 2 = 113
Branch analysis from position: 107
1 jumps found. (Code = 42) Position 1 = 106
Branch analysis from position: 106
Branch analysis from position: 113
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 113
Branch analysis from position: 94
Branch analysis from position: 59
Branch analysis from position: 42
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 19
Branch analysis from position: 27
Branch analysis from position: 19
filename:       /in/pOg2O
function name:  (null)
number of ops:  132
compiled vars:  !0 = $sos, !1 = $usage, !2 = $argv, !3 = $docs, !4 = $iterations, !5 = $i, !6 = $doc, !7 = $start, !8 = $finis, !9 = $mem_empty, !10 = $d, !11 = $time_to_fill, !12 = $time_to_check, !13 = $mem_spl, !14 = $mem_used, !15 = $arr, !16 = $mem_arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   NEW                                              $17     'SplObjectStorage'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $17
    6     3        ASSIGN                                                   !1, 'php+%25s+INTEGER+%09+-+Run+the+SPLObjectStorage+vs.+Array+test+with+INTEGER+size.%0A'
    8     4        COUNT                                            ~21     !2
          5        IS_SMALLER                                               ~21, 2
          6      > JMPZ                                                     ~22, ->13
    9     7    >   INIT_FCALL                                               'printf'
          8        SEND_VAR                                                 !1
          9        FETCH_DIM_R                                      ~23     !2, 0
         10        SEND_VAL                                                 ~23
         11        DO_ICALL                                                 
   10    12      > EXIT                                                     1
   13    13    >   ASSIGN                                                   !3, <array>
   14    14        FETCH_DIM_R                                      ~26     !2, 1
         15        CAST                                          4  ~27     ~26
         16        ASSIGN                                                   !4, ~27
   16    17        ASSIGN                                                   !5, 0
         18      > JMP                                                      ->25
   17    19    >   NEW                                              $30     'DOMDocument'
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !6, $30
   20    22        ASSIGN_DIM                                               !3
         23        OP_DATA                                                  !6
   16    24        PRE_INC                                                  !5
         25    >   IS_SMALLER                                               !5, !4
         26      > JMPNZ                                                    ~35, ->19
   24    27    >   ASSIGN                                           ~36     !8, 0
         28        ASSIGN                                                   !7, ~36
   26    29        INIT_FCALL                                               'memory_get_usage'
         30        DO_ICALL                                         $38     
         31        ASSIGN                                                   !9, $38
   29    32        INIT_FCALL                                               'microtime'
         33        SEND_VAL                                                 <true>
         34        DO_ICALL                                         $40     
         35        ASSIGN                                                   !7, $40
   30    36      > FE_RESET_R                                       $42     !3, ->42
         37    > > FE_FETCH_R                                               $42, !10, ->42
   31    38    >   INIT_METHOD_CALL                                         !0, 'attach'
         39        SEND_VAR_EX                                              !10
         40        DO_FCALL                                      0          
   30    41      > JMP                                                      ->37
         42    >   FE_FREE                                                  $42
   33    43        INIT_FCALL                                               'microtime'
         44        SEND_VAL                                                 <true>
         45        DO_ICALL                                         $44     
         46        ASSIGN                                                   !8, $44
   35    47        SUB                                              ~46     !8, !7
         48        ASSIGN                                                   !11, ~46
   38    49        INIT_FCALL                                               'microtime'
         50        SEND_VAL                                                 <false>
         51        DO_ICALL                                         $48     
         52        ASSIGN                                                   !7, $48
   39    53      > FE_RESET_R                                       $50     !3, ->59
         54    > > FE_FETCH_R                                               $50, !10, ->59
   40    55    >   INIT_METHOD_CALL                                         !0, 'contains'
         56        SEND_VAR_EX                                              !10
         57        DO_FCALL                                      0          
   39    58      > JMP                                                      ->54
         59    >   FE_FREE                                                  $50
   43    60        INIT_FCALL                                               'microtime'
         61        SEND_VAL                                                 <false>
         62        DO_ICALL                                         $52     
         63        ASSIGN                                                   !8, $52
   45    64        SUB                                              ~54     !8, !7
         65        ASSIGN                                                   !12, ~54
   47    66        INIT_FCALL                                               'memory_get_usage'
         67        DO_ICALL                                         $56     
         68        ASSIGN                                                   !13, $56
   49    69        SUB                                              ~58     !13, !9
         70        ASSIGN                                                   !14, ~58
   51    71        INIT_FCALL                                               'printf'
         72        SEND_VAL                                                 'SplObjectStorage%3A%0ATime+to+fill%3A+%250.12f.%0ATime+to+check%3A+%250.12f.%0AMemory%3A+%25d%0A%0A'
         73        SEND_VAR                                                 !11
         74        SEND_VAR                                                 !12
         75        SEND_VAR                                                 !14
         76        DO_ICALL                                                 
   53    77        UNSET_CV                                                 !0
   54    78        INIT_FCALL                                               'memory_get_usage'
         79        DO_ICALL                                         $61     
         80        ASSIGN                                                   !9, $61
   57    81        INIT_FCALL                                               'microtime'
         82        SEND_VAL                                                 <true>
         83        DO_ICALL                                         $63     
         84        ASSIGN                                                   !7, $63
   58    85        ASSIGN                                                   !15, <array>
   61    86      > FE_RESET_R                                       $66     !3, ->94
         87    > > FE_FETCH_R                                               $66, !10, ->94
   62    88    >   INIT_FCALL                                               'spl_object_hash'
         89        SEND_VAR                                                 !10
         90        DO_ICALL                                         $67     
         91        ASSIGN_DIM                                               !15, $67
         92        OP_DATA                                                  !10
   61    93      > JMP                                                      ->87
         94    >   FE_FREE                                                  $66
   64    95        INIT_FCALL                                               'microtime'
         96        SEND_VAL                                                 <true>
         97        DO_ICALL                                         $69     
         98        ASSIGN                                                   !8, $69
   66    99        SUB                                              ~71     !8, !7
        100        ASSIGN                                                   !11, ~71
   69   101        INIT_FCALL                                               'microtime'
        102        SEND_VAL                                                 <false>
        103        DO_ICALL                                         $73     
        104        ASSIGN                                                   !7, $73
   70   105      > FE_RESET_R                                       $75     !3, ->113
        106    > > FE_FETCH_R                                               $75, !10, ->113
   72   107    >   INIT_FCALL                                               'spl_object_hash'
        108        SEND_VAR                                                 !10
        109        DO_ICALL                                         $76     
        110        ISSET_ISEMPTY_DIM_OBJ                         0  ~77     !15, $76
        111        FREE                                                     ~77
   70   112      > JMP                                                      ->106
        113    >   FE_FREE                                                  $75
   75   114        INIT_FCALL                                               'microtime'
        115        SEND_VAL                                                 <false>
        116        DO_ICALL                                         $78     
        117        ASSIGN                                                   !8, $78
   77   118        SUB                                              ~80     !8, !7
        119        ASSIGN                                                   !12, ~80
   78   120        INIT_FCALL                                               'memory_get_usage'
        121        DO_ICALL                                         $82     
        122        ASSIGN                                                   !16, $82
   80   123        SUB                                              ~84     !16, !9
        124        ASSIGN                                                   !14, ~84
   83   125        INIT_FCALL                                               'printf'
        126        SEND_VAL                                                 'Arrays%3A%0ATime+to+fill%3A+%250.12f.%0ATime+to+check%3A+%250.12f.%0AMemory%3A+%25d%0A%0A'
        127        SEND_VAR                                                 !11
        128        SEND_VAR                                                 !12
        129        SEND_VAR                                                 !14
        130        DO_ICALL                                                 
        131      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.64 ms | 1408 KiB | 21 Q