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"; $docs = array(); $iterations = 100000; //100000; echo "Count of DOMDocuments: {$iterations}" . PHP_EOL. PHP_EOL; 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(true); foreach ($docs as $d) { $sos->contains($d); } $finis = microtime(true); $time_to_check = $finis - $start; $mem_spl = memory_get_usage(); $mem_used = $mem_spl - $mem_empty; printf("SplObjectStorage:\nTime to fill: %0.12f. [s]\nTime to check: %0.12f. [s]\nMemory: %d [MB]\n\n", $time_to_fill, $time_to_check, $mem_used/1024/1024); unset($sos); $mem_empty = memory_get_usage(); // Test arrays: $start = microtime(TRUE); $arr = new SplFixedArray($iterations); // Load the array $_i = 0; foreach ($docs as $d) { $arr[$_i] = $d; $_i++; } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the array $start = microtime(FALSE); $_i = 0; foreach ($docs as $d) { isset($arr[$_i]); $_i++; } $finis = microtime(FALSE); $time_to_check = $finis - $start; $mem_arr = memory_get_usage(); $mem_used = $mem_arr - $mem_empty; printf("SplFixedArray:\nTime to fill: %0.12f. [s]\nTime to check: %0.12f. [s]\nMemory: %d [MB]\n\n", $time_to_fill, $time_to_check, $mem_used/1024/1024); $mem_empty = memory_get_usage(); // Test arrays: $start = microtime(TRUE); $arr = array(); $_i =0; // Load the array foreach ($docs as $d) { $arr[$_i] = $d; $_i++; } $finis = microtime(TRUE); $time_to_fill = $finis - $start; // Check membership on the array $start = microtime(FALSE); $_i =0; foreach ($docs as $d) { isset($arr[$_i]); $_i++; } $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. [s]\nTime to check: %0.12f. [s]\nMemory: %d [MB]\n\n", $time_to_fill, $time_to_check, $mem_used/1024/1024); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 13
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 36
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 48, Position 2 = 53
Branch analysis from position: 48
2 jumps found. (Code = 78) Position 1 = 49, Position 2 = 53
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 53
2 jumps found. (Code = 77) Position 1 = 87, Position 2 = 92
Branch analysis from position: 87
2 jumps found. (Code = 78) Position 1 = 88, Position 2 = 92
Branch analysis from position: 88
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
Branch analysis from position: 92
2 jumps found. (Code = 77) Position 1 = 105, Position 2 = 110
Branch analysis from position: 105
2 jumps found. (Code = 78) Position 1 = 106, Position 2 = 110
Branch analysis from position: 106
1 jumps found. (Code = 42) Position 1 = 105
Branch analysis from position: 105
Branch analysis from position: 110
2 jumps found. (Code = 77) Position 1 = 140, Position 2 = 145
Branch analysis from position: 140
2 jumps found. (Code = 78) Position 1 = 141, Position 2 = 145
Branch analysis from position: 141
1 jumps found. (Code = 42) Position 1 = 140
Branch analysis from position: 140
Branch analysis from position: 145
2 jumps found. (Code = 77) Position 1 = 158, Position 2 = 163
Branch analysis from position: 158
2 jumps found. (Code = 78) Position 1 = 159, Position 2 = 163
Branch analysis from position: 159
1 jumps found. (Code = 42) Position 1 = 158
Branch analysis from position: 158
Branch analysis from position: 163
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 163
Branch analysis from position: 145
Branch analysis from position: 110
Branch analysis from position: 92
Branch analysis from position: 53
Branch analysis from position: 36
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 13
Branch analysis from position: 21
Branch analysis from position: 13
filename:       /in/tqttt
function name:  (null)
number of ops:  184
compiled vars:  !0 = $sos, !1 = $usage, !2 = $docs, !3 = $iterations, !4 = $i, !5 = $doc, !6 = $start, !7 = $finis, !8 = $mem_empty, !9 = $d, !10 = $time_to_fill, !11 = $time_to_check, !12 = $mem_spl, !13 = $mem_used, !14 = $arr, !15 = $_i, !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        ASSIGN                                                   !2, <array>
    9     5        ASSIGN                                                   !3, 100000
   11     6        NOP                                                      
          7        FAST_CONCAT                                      ~23     'Count+of+DOMDocuments%3A+', !3
          8        CONCAT                                           ~24     ~23, '%0A'
          9        CONCAT                                           ~25     ~24, '%0A'
         10        ECHO                                                     ~25
   13    11        ASSIGN                                                   !4, 0
         12      > JMP                                                      ->19
   14    13    >   NEW                                              $27     'DOMDocument'
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !5, $27
   17    16        ASSIGN_DIM                                               !2
         17        OP_DATA                                                  !5
   13    18        PRE_INC                                                  !4
         19    >   IS_SMALLER                                               !4, !3
         20      > JMPNZ                                                    ~32, ->13
   23    21    >   ASSIGN                                           ~33     !7, 0
         22        ASSIGN                                                   !6, ~33
   25    23        INIT_FCALL                                               'memory_get_usage'
         24        DO_ICALL                                         $35     
         25        ASSIGN                                                   !8, $35
   28    26        INIT_FCALL                                               'microtime'
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $37     
         29        ASSIGN                                                   !6, $37
   29    30      > FE_RESET_R                                       $39     !2, ->36
         31    > > FE_FETCH_R                                               $39, !9, ->36
   30    32    >   INIT_METHOD_CALL                                         !0, 'attach'
         33        SEND_VAR_EX                                              !9
         34        DO_FCALL                                      0          
   29    35      > JMP                                                      ->31
         36    >   FE_FREE                                                  $39
   32    37        INIT_FCALL                                               'microtime'
         38        SEND_VAL                                                 <true>
         39        DO_ICALL                                         $41     
         40        ASSIGN                                                   !7, $41
   34    41        SUB                                              ~43     !7, !6
         42        ASSIGN                                                   !10, ~43
   37    43        INIT_FCALL                                               'microtime'
         44        SEND_VAL                                                 <true>
         45        DO_ICALL                                         $45     
         46        ASSIGN                                                   !6, $45
   38    47      > FE_RESET_R                                       $47     !2, ->53
         48    > > FE_FETCH_R                                               $47, !9, ->53
   39    49    >   INIT_METHOD_CALL                                         !0, 'contains'
         50        SEND_VAR_EX                                              !9
         51        DO_FCALL                                      0          
   38    52      > JMP                                                      ->48
         53    >   FE_FREE                                                  $47
   42    54        INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $49     
         57        ASSIGN                                                   !7, $49
   44    58        SUB                                              ~51     !7, !6
         59        ASSIGN                                                   !11, ~51
   46    60        INIT_FCALL                                               'memory_get_usage'
         61        DO_ICALL                                         $53     
         62        ASSIGN                                                   !12, $53
   48    63        SUB                                              ~55     !12, !8
         64        ASSIGN                                                   !13, ~55
   50    65        INIT_FCALL                                               'printf'
         66        SEND_VAL                                                 'SplObjectStorage%3A%0ATime+to+fill%3A+%250.12f.+%5Bs%5D%0ATime+to+check%3A+%250.12f.+%5Bs%5D%0AMemory%3A+%25d+%5BMB%5D%0A%0A'
         67        SEND_VAR                                                 !10
         68        SEND_VAR                                                 !11
         69        DIV                                              ~57     !13, 1024
         70        DIV                                              ~58     ~57, 1024
         71        SEND_VAL                                                 ~58
         72        DO_ICALL                                                 
   52    73        UNSET_CV                                                 !0
   59    74        INIT_FCALL                                               'memory_get_usage'
         75        DO_ICALL                                         $60     
         76        ASSIGN                                                   !8, $60
   62    77        INIT_FCALL                                               'microtime'
         78        SEND_VAL                                                 <true>
         79        DO_ICALL                                         $62     
         80        ASSIGN                                                   !6, $62
   63    81        NEW                                              $64     'SplFixedArray'
         82        SEND_VAR_EX                                              !3
         83        DO_FCALL                                      0          
         84        ASSIGN                                                   !14, $64
   66    85        ASSIGN                                                   !15, 0
   67    86      > FE_RESET_R                                       $68     !2, ->92
         87    > > FE_FETCH_R                                               $68, !9, ->92
   68    88    >   ASSIGN_DIM                                               !14, !15
         89        OP_DATA                                                  !9
   69    90        PRE_INC                                                  !15
   67    91      > JMP                                                      ->87
         92    >   FE_FREE                                                  $68
   71    93        INIT_FCALL                                               'microtime'
         94        SEND_VAL                                                 <true>
         95        DO_ICALL                                         $71     
         96        ASSIGN                                                   !7, $71
   73    97        SUB                                              ~73     !7, !6
         98        ASSIGN                                                   !10, ~73
   76    99        INIT_FCALL                                               'microtime'
        100        SEND_VAL                                                 <false>
        101        DO_ICALL                                         $75     
        102        ASSIGN                                                   !6, $75
   78   103        ASSIGN                                                   !15, 0
   79   104      > FE_RESET_R                                       $78     !2, ->110
        105    > > FE_FETCH_R                                               $78, !9, ->110
   80   106    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~79     !14, !15
        107        FREE                                                     ~79
   81   108        PRE_INC                                                  !15
   79   109      > JMP                                                      ->105
        110    >   FE_FREE                                                  $78
   84   111        INIT_FCALL                                               'microtime'
        112        SEND_VAL                                                 <false>
        113        DO_ICALL                                         $81     
        114        ASSIGN                                                   !7, $81
   86   115        SUB                                              ~83     !7, !6
        116        ASSIGN                                                   !11, ~83
   87   117        INIT_FCALL                                               'memory_get_usage'
        118        DO_ICALL                                         $85     
        119        ASSIGN                                                   !16, $85
   89   120        SUB                                              ~87     !16, !8
        121        ASSIGN                                                   !13, ~87
   92   122        INIT_FCALL                                               'printf'
        123        SEND_VAL                                                 'SplFixedArray%3A%0ATime+to+fill%3A+%250.12f.+%5Bs%5D%0ATime+to+check%3A+%250.12f.+%5Bs%5D%0AMemory%3A+%25d+%5BMB%5D%0A%0A'
        124        SEND_VAR                                                 !10
        125        SEND_VAR                                                 !11
        126        DIV                                              ~89     !13, 1024
        127        DIV                                              ~90     ~89, 1024
        128        SEND_VAL                                                 ~90
        129        DO_ICALL                                                 
  102   130        INIT_FCALL                                               'memory_get_usage'
        131        DO_ICALL                                         $92     
        132        ASSIGN                                                   !8, $92
  105   133        INIT_FCALL                                               'microtime'
        134        SEND_VAL                                                 <true>
        135        DO_ICALL                                         $94     
        136        ASSIGN                                                   !6, $94
  106   137        ASSIGN                                                   !14, <array>
  108   138        ASSIGN                                                   !15, 0
  110   139      > FE_RESET_R                                       $98     !2, ->145
        140    > > FE_FETCH_R                                               $98, !9, ->145
  111   141    >   ASSIGN_DIM                                               !14, !15
        142        OP_DATA                                                  !9
  112   143        PRE_INC                                                  !15
  110   144      > JMP                                                      ->140
        145    >   FE_FREE                                                  $98
  114   146        INIT_FCALL                                               'microtime'
        147        SEND_VAL                                                 <true>
        148        DO_ICALL                                         $101    
        149        ASSIGN                                                   !7, $101
  116   150        SUB                                              ~103    !7, !6
        151        ASSIGN                                                   !10, ~103
  119   152        INIT_FCALL                                               'microtime'
        153        SEND_VAL                                                 <false>
        154        DO_ICALL                                         $105    
        155        ASSIGN                                                   !6, $105
  120   156        ASSIGN                                                   !15, 0
  121   157      > FE_RESET_R                                       $108    !2, ->163
        158    > > FE_FETCH_R                                               $108, !9, ->163
  122   159    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~109    !14, !15
        160        FREE                                                     ~109
  123   161        PRE_INC                                                  !15
  121   162      > JMP                                                      ->158
        163    >   FE_FREE                                                  $108
  126   164        INIT_FCALL                                               'microtime'
        165        SEND_VAL                                                 <false>
        166        DO_ICALL                                         $111    
        167        ASSIGN                                                   !7, $111
  128   168        SUB                                              ~113    !7, !6
        169        ASSIGN                                                   !11, ~113
  129   170        INIT_FCALL                                               'memory_get_usage'
        171        DO_ICALL                                         $115    
        172        ASSIGN                                                   !16, $115
  131   173        SUB                                              ~117    !16, !8
        174        ASSIGN                                                   !13, ~117
  134   175        INIT_FCALL                                               'printf'
        176        SEND_VAL                                                 'Arrays%3A%0ATime+to+fill%3A+%250.12f.+%5Bs%5D%0ATime+to+check%3A+%250.12f.+%5Bs%5D%0AMemory%3A+%25d+%5BMB%5D%0A%0A'
        177        SEND_VAR                                                 !10
        178        SEND_VAR                                                 !11
        179        DIV                                              ~119    !13, 1024
        180        DIV                                              ~120    ~119, 1024
        181        SEND_VAL                                                 ~120
        182        DO_ICALL                                                 
  135   183      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.11 ms | 1412 KiB | 19 Q