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 = 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
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 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 22
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 45
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 45
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 45
2 jumps found. (Code = 77) Position 1 = 57, Position 2 = 62
Branch analysis from position: 57
2 jumps found. (Code = 78) Position 1 = 58, Position 2 = 62
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 62
2 jumps found. (Code = 77) Position 1 = 96, Position 2 = 101
Branch analysis from position: 96
2 jumps found. (Code = 78) Position 1 = 97, Position 2 = 101
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
Branch analysis from position: 101
2 jumps found. (Code = 77) Position 1 = 114, Position 2 = 119
Branch analysis from position: 114
2 jumps found. (Code = 78) Position 1 = 115, Position 2 = 119
Branch analysis from position: 115
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
Branch analysis from position: 119
2 jumps found. (Code = 77) Position 1 = 149, Position 2 = 154
Branch analysis from position: 149
2 jumps found. (Code = 78) Position 1 = 150, Position 2 = 154
Branch analysis from position: 150
1 jumps found. (Code = 42) Position 1 = 149
Branch analysis from position: 149
Branch analysis from position: 154
2 jumps found. (Code = 77) Position 1 = 167, Position 2 = 172
Branch analysis from position: 167
2 jumps found. (Code = 78) Position 1 = 168, Position 2 = 172
Branch analysis from position: 168
1 jumps found. (Code = 42) Position 1 = 167
Branch analysis from position: 167
Branch analysis from position: 172
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 172
Branch analysis from position: 154
Branch analysis from position: 119
Branch analysis from position: 101
Branch analysis from position: 62
Branch analysis from position: 45
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 22
Branch analysis from position: 30
Branch analysis from position: 22
filename:       /in/2vaj9
function name:  (null)
number of ops:  193
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 = $_i, !17 = $mem_arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   NEW                                              $18     'SplObjectStorage'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $18
    6     3        ASSIGN                                                   !1, 'php+%25s+INTEGER+%09+-+Run+the+SPLObjectStorage+vs.+Array+test+with+INTEGER+size.%0A'
    8     4        COUNT                                            ~22     !2
          5        IS_SMALLER                                               ~22, 2
          6      > JMPZ                                                     ~23, ->13
    9     7    >   INIT_FCALL                                               'printf'
          8        SEND_VAR                                                 !1
          9        FETCH_DIM_R                                      ~24     !2, 0
         10        SEND_VAL                                                 ~24
         11        DO_ICALL                                                 
   10    12      > EXIT                                                     1
   13    13    >   ASSIGN                                                   !3, <array>
   14    14        ASSIGN                                                   !4, 100000
   16    15        NOP                                                      
         16        FAST_CONCAT                                      ~28     'Count+of+DOMDocuments%3A+', !4
         17        CONCAT                                           ~29     ~28, '%0A'
         18        CONCAT                                           ~30     ~29, '%0A'
         19        ECHO                                                     ~30
   18    20        ASSIGN                                                   !5, 0
         21      > JMP                                                      ->28
   19    22    >   NEW                                              $32     'DOMDocument'
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !6, $32
   22    25        ASSIGN_DIM                                               !3
         26        OP_DATA                                                  !6
   18    27        PRE_INC                                                  !5
         28    >   IS_SMALLER                                               !5, !4
         29      > JMPNZ                                                    ~37, ->22
   28    30    >   ASSIGN                                           ~38     !8, 0
         31        ASSIGN                                                   !7, ~38
   30    32        INIT_FCALL                                               'memory_get_usage'
         33        DO_ICALL                                         $40     
         34        ASSIGN                                                   !9, $40
   33    35        INIT_FCALL                                               'microtime'
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $42     
         38        ASSIGN                                                   !7, $42
   34    39      > FE_RESET_R                                       $44     !3, ->45
         40    > > FE_FETCH_R                                               $44, !10, ->45
   35    41    >   INIT_METHOD_CALL                                         !0, 'attach'
         42        SEND_VAR_EX                                              !10
         43        DO_FCALL                                      0          
   34    44      > JMP                                                      ->40
         45    >   FE_FREE                                                  $44
   37    46        INIT_FCALL                                               'microtime'
         47        SEND_VAL                                                 <true>
         48        DO_ICALL                                         $46     
         49        ASSIGN                                                   !8, $46
   39    50        SUB                                              ~48     !8, !7
         51        ASSIGN                                                   !11, ~48
   42    52        INIT_FCALL                                               'microtime'
         53        SEND_VAL                                                 <true>
         54        DO_ICALL                                         $50     
         55        ASSIGN                                                   !7, $50
   43    56      > FE_RESET_R                                       $52     !3, ->62
         57    > > FE_FETCH_R                                               $52, !10, ->62
   44    58    >   INIT_METHOD_CALL                                         !0, 'contains'
         59        SEND_VAR_EX                                              !10
         60        DO_FCALL                                      0          
   43    61      > JMP                                                      ->57
         62    >   FE_FREE                                                  $52
   47    63        INIT_FCALL                                               'microtime'
         64        SEND_VAL                                                 <true>
         65        DO_ICALL                                         $54     
         66        ASSIGN                                                   !8, $54
   49    67        SUB                                              ~56     !8, !7
         68        ASSIGN                                                   !12, ~56
   51    69        INIT_FCALL                                               'memory_get_usage'
         70        DO_ICALL                                         $58     
         71        ASSIGN                                                   !13, $58
   53    72        SUB                                              ~60     !13, !9
         73        ASSIGN                                                   !14, ~60
   55    74        INIT_FCALL                                               'printf'
         75        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'
         76        SEND_VAR                                                 !11
         77        SEND_VAR                                                 !12
         78        DIV                                              ~62     !14, 1024
         79        DIV                                              ~63     ~62, 1024
         80        SEND_VAL                                                 ~63
         81        DO_ICALL                                                 
   57    82        UNSET_CV                                                 !0
   64    83        INIT_FCALL                                               'memory_get_usage'
         84        DO_ICALL                                         $65     
         85        ASSIGN                                                   !9, $65
   67    86        INIT_FCALL                                               'microtime'
         87        SEND_VAL                                                 <true>
         88        DO_ICALL                                         $67     
         89        ASSIGN                                                   !7, $67
   68    90        NEW                                              $69     'SplFixedArray'
         91        SEND_VAR_EX                                              !4
         92        DO_FCALL                                      0          
         93        ASSIGN                                                   !15, $69
   71    94        ASSIGN                                                   !16, 0
   72    95      > FE_RESET_R                                       $73     !3, ->101
         96    > > FE_FETCH_R                                               $73, !10, ->101
   73    97    >   ASSIGN_DIM                                               !15, !16
         98        OP_DATA                                                  !10
   74    99        PRE_INC                                                  !16
   72   100      > JMP                                                      ->96
        101    >   FE_FREE                                                  $73
   76   102        INIT_FCALL                                               'microtime'
        103        SEND_VAL                                                 <true>
        104        DO_ICALL                                         $76     
        105        ASSIGN                                                   !8, $76
   78   106        SUB                                              ~78     !8, !7
        107        ASSIGN                                                   !11, ~78
   81   108        INIT_FCALL                                               'microtime'
        109        SEND_VAL                                                 <false>
        110        DO_ICALL                                         $80     
        111        ASSIGN                                                   !7, $80
   83   112        ASSIGN                                                   !16, 0
   84   113      > FE_RESET_R                                       $83     !3, ->119
        114    > > FE_FETCH_R                                               $83, !10, ->119
   85   115    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~84     !15, !16
        116        FREE                                                     ~84
   86   117        PRE_INC                                                  !16
   84   118      > JMP                                                      ->114
        119    >   FE_FREE                                                  $83
   89   120        INIT_FCALL                                               'microtime'
        121        SEND_VAL                                                 <false>
        122        DO_ICALL                                         $86     
        123        ASSIGN                                                   !8, $86
   91   124        SUB                                              ~88     !8, !7
        125        ASSIGN                                                   !12, ~88
   92   126        INIT_FCALL                                               'memory_get_usage'
        127        DO_ICALL                                         $90     
        128        ASSIGN                                                   !17, $90
   94   129        SUB                                              ~92     !17, !9
        130        ASSIGN                                                   !14, ~92
   97   131        INIT_FCALL                                               'printf'
        132        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'
        133        SEND_VAR                                                 !11
        134        SEND_VAR                                                 !12
        135        DIV                                              ~94     !14, 1024
        136        DIV                                              ~95     ~94, 1024
        137        SEND_VAL                                                 ~95
        138        DO_ICALL                                                 
  107   139        INIT_FCALL                                               'memory_get_usage'
        140        DO_ICALL                                         $97     
        141        ASSIGN                                                   !9, $97
  110   142        INIT_FCALL                                               'microtime'
        143        SEND_VAL                                                 <true>
        144        DO_ICALL                                         $99     
        145        ASSIGN                                                   !7, $99
  111   146        ASSIGN                                                   !15, <array>
  113   147        ASSIGN                                                   !16, 0
  115   148      > FE_RESET_R                                       $103    !3, ->154
        149    > > FE_FETCH_R                                               $103, !10, ->154
  116   150    >   ASSIGN_DIM                                               !15, !16
        151        OP_DATA                                                  !10
  117   152        PRE_INC                                                  !16
  115   153      > JMP                                                      ->149
        154    >   FE_FREE                                                  $103
  119   155        INIT_FCALL                                               'microtime'
        156        SEND_VAL                                                 <true>
        157        DO_ICALL                                         $106    
        158        ASSIGN                                                   !8, $106
  121   159        SUB                                              ~108    !8, !7
        160        ASSIGN                                                   !11, ~108
  124   161        INIT_FCALL                                               'microtime'
        162        SEND_VAL                                                 <false>
        163        DO_ICALL                                         $110    
        164        ASSIGN                                                   !7, $110
  125   165        ASSIGN                                                   !16, 0
  126   166      > FE_RESET_R                                       $113    !3, ->172
        167    > > FE_FETCH_R                                               $113, !10, ->172
  127   168    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~114    !15, !16
        169        FREE                                                     ~114
  128   170        PRE_INC                                                  !16
  126   171      > JMP                                                      ->167
        172    >   FE_FREE                                                  $113
  131   173        INIT_FCALL                                               'microtime'
        174        SEND_VAL                                                 <false>
        175        DO_ICALL                                         $116    
        176        ASSIGN                                                   !8, $116
  133   177        SUB                                              ~118    !8, !7
        178        ASSIGN                                                   !12, ~118
  134   179        INIT_FCALL                                               'memory_get_usage'
        180        DO_ICALL                                         $120    
        181        ASSIGN                                                   !17, $120
  136   182        SUB                                              ~122    !17, !9
        183        ASSIGN                                                   !14, ~122
  139   184        INIT_FCALL                                               'printf'
        185        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'
        186        SEND_VAR                                                 !11
        187        SEND_VAR                                                 !12
        188        DIV                                              ~124    !14, 1024
        189        DIV                                              ~125    ~124, 1024
        190        SEND_VAL                                                 ~125
        191        DO_ICALL                                                 
  140   192      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.64 ms | 1412 KiB | 19 Q