3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.98 ms | 1032 KiB | 17 Q