3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Creating dummy variables for ($i = 0; $i < 500; ++$i) ${md5(microtime(true))} = openssl_random_pseudo_bytes(mt_rand(1, 1000)); $items = ["one", "two", "three"]; $ignore = "two"; $iterations = 1000; $preStartTime = microtime(true); for ($i = 0; $i < $iterations; ++$i) { array_filter($items, call_user_func(function ($context·cfcd208495d565ef66e7dff9f98764da) { return function ($item) use ($context·cfcd208495d565ef66e7dff9f98764da) { extract($context·cfcd208495d565ef66e7dff9f98764da); return $item !== $ignore; }; }, get_defined_vars())); } $preTime = microtime(true) - $preStartTime; $vanillaStartTime = microtime(true); for ($i = 0; $i < $iterations; ++$i) { array_filter($items, function ($item) use ($ignore) { return $item !== $ignore; }); } $vanillaTime = microtime(true) - $vanillaStartTime; echo 'Pre: '.($preTime*1000).'ms'.PHP_EOL; echo 'Vanilla: '.($vanillaTime*1000).'ms'.PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 29
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 53
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 53
Branch analysis from position: 62
Branch analysis from position: 53
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 29
Branch analysis from position: 42
Branch analysis from position: 29
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 2
Branch analysis from position: 20
Branch analysis from position: 2
filename:       /in/tTLRk
function name:  (null)
number of ops:  78
compiled vars:  !0 = $i, !1 = $items, !2 = $ignore, !3 = $iterations, !4 = $preStartTime, !5 = $preTime, !6 = $vanillaStartTime, !7 = $vanillaTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->18
    4     2    >   INIT_FCALL                                               'md5'
          3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $9      
          6        SEND_VAR                                                 $9
          7        DO_ICALL                                         $10     
          8        INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
          9        INIT_FCALL                                               'mt_rand'
         10        SEND_VAL                                                 1
         11        SEND_VAL                                                 1000
         12        DO_ICALL                                         $12     
         13        SEND_VAR_NO_REF_EX                                       $12
         14        DO_FCALL                                      0  $13     
         15        FETCH_W                      local               $11     $10
         16        ASSIGN                                                   $11, $13
    3    17        PRE_INC                                                  !0
         18    >   IS_SMALLER                                               !0, 500
         19      > JMPNZ                                                    ~16, ->2
    6    20    >   ASSIGN                                                   !1, <array>
    7    21        ASSIGN                                                   !2, 'two'
    8    22        ASSIGN                                                   !3, 1000
   10    23        INIT_FCALL                                               'microtime'
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $20     
         26        ASSIGN                                                   !4, $20
   11    27        ASSIGN                                                   !0, 0
         28      > JMP                                                      ->40
   12    29    >   INIT_FCALL                                               'array_filter'
         30        SEND_VAR                                                 !1
         31        DECLARE_LAMBDA_FUNCTION                          ~23     [0]
   17    32        INIT_USER_CALL                                1          'call_user_func', ~23
         33        INIT_FCALL                                               'get_defined_vars'
         34        DO_ICALL                                         $24     
         35        SEND_USER                                                $24
         36        DO_FCALL                                      0  $25     
         37        SEND_VAR                                                 $25
   12    38        DO_ICALL                                                 
   11    39        PRE_INC                                                  !0
         40    >   IS_SMALLER                                               !0, !3
         41      > JMPNZ                                                    ~28, ->29
   19    42    >   INIT_FCALL                                               'microtime'
         43        SEND_VAL                                                 <true>
         44        DO_ICALL                                         $29     
         45        SUB                                              ~30     $29, !4
         46        ASSIGN                                                   !5, ~30
   21    47        INIT_FCALL                                               'microtime'
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $32     
         50        ASSIGN                                                   !6, $32
   22    51        ASSIGN                                                   !0, 0
         52      > JMP                                                      ->60
   23    53    >   INIT_FCALL                                               'array_filter'
         54        SEND_VAR                                                 !1
         55        DECLARE_LAMBDA_FUNCTION                          ~35     [1]
         56        BIND_LEXICAL                                             ~35, !2
   25    57        SEND_VAL                                                 ~35
   23    58        DO_ICALL                                                 
   22    59        PRE_INC                                                  !0
         60    >   IS_SMALLER                                               !0, !3
         61      > JMPNZ                                                    ~38, ->53
   27    62    >   INIT_FCALL                                               'microtime'
         63        SEND_VAL                                                 <true>
         64        DO_ICALL                                         $39     
         65        SUB                                              ~40     $39, !6
         66        ASSIGN                                                   !7, ~40
   29    67        MUL                                              ~42     !5, 1000
         68        CONCAT                                           ~43     'Pre%3A+++++', ~42
         69        CONCAT                                           ~44     ~43, 'ms'
         70        CONCAT                                           ~45     ~44, '%0A'
         71        ECHO                                                     ~45
   30    72        MUL                                              ~46     !7, 1000
         73        CONCAT                                           ~47     'Vanilla%3A+', ~46
         74        CONCAT                                           ~48     ~47, 'ms'
         75        CONCAT                                           ~49     ~48, '%0A'
         76        ECHO                                                     ~49
         77      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tTLRk
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $context·cfcd208495d565ef66e7dff9f98764da
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          2        BIND_LEXICAL                                             ~1, !0
   16     3      > RETURN                                                   ~1
   17     4*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tTLRk
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $item, !1 = $context·cfcd208495d565ef66e7dff9f98764da, !2 = $ignore
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   14     2        INIT_FCALL                                               'extract'
          3        SEND_REF                                                 !1
          4        DO_ICALL                                                 
   15     5        IS_NOT_IDENTICAL                                 ~4      !0, !2
          6      > RETURN                                                   ~4
   16     7*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tTLRk
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $item, !1 = $ignore
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   24     2        IS_NOT_IDENTICAL                                 ~2      !0, !1
          3      > RETURN                                                   ~2
   25     4*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.69 ms | 1020 KiB | 19 Q