3v4l.org

run code in 300+ PHP versions simultaneously
<?php $entries = []; for($i = 0; $i < 100000; $i++) { $entries[] = ['id' => $i]; } $t = microtime(true); $res = array_map(function($entry) { return $entry['id']; }, $entries); $t = microtime(true) - $t; echo 'array_map() took ' . number_format($t, 3) . ' seconds'; $t = microtime(true); $res = []; foreach($entries as $entry) { $res[] = $entry['id']; } $t = microtime(true) - $t; echo "\n"; echo 'foreach took ' . number_format($t, 3) . ' seconds';

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 3
Branch analysis from position: 9
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
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 3
Branch analysis from position: 9
Branch analysis from position: 3
filename:       /in/MZnfH
function name:  (null)
number of ops:  57
compiled vars:  !0 = $entries, !1 = $i, !2 = $t, !3 = $res, !4 = $entry
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->7
    5     3    >   INIT_ARRAY                                       ~8      !1, 'id'
          4        ASSIGN_DIM                                               !0
          5        OP_DATA                                                  ~8
    4     6        PRE_INC                                                  !1
          7    >   IS_SMALLER                                               !1, 100000
          8      > JMPNZ                                                    ~10, ->3
    8     9    >   INIT_FCALL                                               'microtime'
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !2, $11
    9    13        INIT_FCALL                                               'array_map'
         14        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FMZnfH%3A9%240'
         15        SEND_VAL                                                 ~13
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $14     
         18        ASSIGN                                                   !3, $14
   10    19        INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $16     
         22        SUB                                              ~17     $16, !2
         23        ASSIGN                                                   !2, ~17
   12    24        INIT_FCALL                                               'number_format'
         25        SEND_VAR                                                 !2
         26        SEND_VAL                                                 3
         27        DO_ICALL                                         $19     
         28        CONCAT                                           ~20     'array_map%28%29+took+', $19
         29        CONCAT                                           ~21     ~20, '+seconds'
         30        ECHO                                                     ~21
   14    31        INIT_FCALL                                               'microtime'
         32        SEND_VAL                                                 <true>
         33        DO_ICALL                                         $22     
         34        ASSIGN                                                   !2, $22
   15    35        ASSIGN                                                   !3, <array>
   16    36      > FE_RESET_R                                       $25     !0, ->42
         37    > > FE_FETCH_R                                               $25, !4, ->42
   17    38    >   FETCH_DIM_R                                      ~27     !4, 'id'
         39        ASSIGN_DIM                                               !3
         40        OP_DATA                                                  ~27
   16    41      > JMP                                                      ->37
         42    >   FE_FREE                                                  $25
   19    43        INIT_FCALL                                               'microtime'
         44        SEND_VAL                                                 <true>
         45        DO_ICALL                                         $28     
         46        SUB                                              ~29     $28, !2
         47        ASSIGN                                                   !2, ~29
   21    48        ECHO                                                     '%0A'
   22    49        INIT_FCALL                                               'number_format'
         50        SEND_VAR                                                 !2
         51        SEND_VAL                                                 3
         52        DO_ICALL                                         $31     
         53        CONCAT                                           ~32     'foreach+took+', $31
         54        CONCAT                                           ~33     ~32, '+seconds'
         55        ECHO                                                     ~33
         56      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FMZnfH%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MZnfH
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $entry
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'id'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FMZnfH%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.11 ms | 1392 KiB | 19 Q