3v4l.org

run code in 500+ PHP versions simultaneously
<?php $items = []; for ($i = 0; $i < 3000; $i++) { $items[] = [ 'foo' => 1, 'qty' => ($i%7)+1, 'bar' => 2, 'weight' => ($i%2)+1, 'baz' => 3, ]; } $start =microtime(1); $count = count($items); $weights = array_sum(array_column($items, 'weight')); $qty = array_sum(array_column($items, 'qty')); Echo ($qty * $weights)/$count ."\n"; Echo (microtime(1)-$start)*100;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 3
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 3
Branch analysis from position: 17
Branch analysis from position: 3
filename:       /in/c3CIg
function name:  (null)
number of ops:  50
compiled vars:  !0 = $items, !1 = $i, !2 = $start, !3 = $count, !4 = $weights, !5 = $qty
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, 0
          2      > JMP                                                          ->15
    6     3    >   INIT_ARRAY                                           ~9      1, 'foo'
    7     4        MOD                                                  ~10     !1, 7
          5        ADD                                                  ~11     ~10, 1
          6        ADD_ARRAY_ELEMENT                                    ~9      ~11, 'qty'
    8     7        ADD_ARRAY_ELEMENT                                    ~9      2, 'bar'
    9     8        MOD                                                  ~12     !1, 2
          9        ADD                                                  ~13     ~12, 1
         10        ADD_ARRAY_ELEMENT                                    ~9      ~13, 'weight'
   10    11        ADD_ARRAY_ELEMENT                                    ~9      3, 'baz'
    5    12        ASSIGN_DIM                                                   !0
   10    13        OP_DATA                                                      ~9
    4    14        PRE_INC                                                      !1
         15    >   IS_SMALLER                                                   !1, 3000
         16      > JMPNZ                                                        ~15, ->3
   14    17    >   INIT_FCALL                                                   'microtime'
         18        SEND_VAL                                                     1
         19        DO_ICALL                                             $16     
         20        ASSIGN                                                       !2, $16
   15    21        COUNT                                                ~18     !0
         22        ASSIGN                                                       !3, ~18
   16    23        INIT_FCALL                                                   'array_sum'
         24        INIT_FCALL                                                   'array_column'
         25        SEND_VAR                                                     !0
         26        SEND_VAL                                                     'weight'
         27        DO_ICALL                                             $20     
         28        SEND_VAR                                                     $20
         29        DO_ICALL                                             $21     
         30        ASSIGN                                                       !4, $21
   17    31        INIT_FCALL                                                   'array_sum'
         32        INIT_FCALL                                                   'array_column'
         33        SEND_VAR                                                     !0
         34        SEND_VAL                                                     'qty'
         35        DO_ICALL                                             $23     
         36        SEND_VAR                                                     $23
         37        DO_ICALL                                             $24     
         38        ASSIGN                                                       !5, $24
   19    39        MUL                                                  ~26     !5, !4
         40        DIV                                                  ~27     ~26, !3
         41        CONCAT                                               ~28     ~27, '%0A'
         42        ECHO                                                         ~28
   20    43        INIT_FCALL                                                   'microtime'
         44        SEND_VAL                                                     1
         45        DO_ICALL                                             $29     
         46        SUB                                                  ~30     $29, !2
         47        MUL                                                  ~31     ~30, 100
         48        ECHO                                                         ~31
   21    49      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.85 ms | 1235 KiB | 16 Q