3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $this->last_result analogue in WPDB for 1000 posts' "SELECT meta_key, meta_value WHERE...." $last_result = array_fill( 0, 2000, (object) [ 'meta_key' => 'hello_who', 'meta_value' => str_repeat( 'World and WordPress ', 20 ), ] ); const ARRAY_N = 0b0; $output = 0b0; // Startup engines; number_format( hrtime( true ) / 1e9 ); $new_array = []; foreach ( (array) $last_result as $row ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } $new_array = []; foreach ( (array) $last_result as $row ) { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } $new_array = []; // Test. $new_array = []; $t = hrtime( true ); foreach ( (array) $last_result as $row ) { if ( ARRAY_N === $output ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } else { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } } echo 'Old ARRAY_N: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n"; $new_array = []; $t = hrtime( true ); if ( ARRAY_N === $output ) { foreach ( (array) $last_result as $row ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } } else { foreach ( (array) $last_result as $row ) { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } } echo 'New ARRAY_N: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n"; // Test ARRAY_A now. $output = 0b1; $new_array = []; $t = hrtime( true ); foreach ( (array) $last_result as $row ) { if ( ARRAY_N === $output ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } else { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } } echo 'Old ARRAY_A: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n"; $new_array = []; $t = hrtime( true ); if ( ARRAY_N === $output ) { foreach ( (array) $last_result as $row ) { // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } } else { foreach ( (array) $last_result as $row ) { // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } } echo 'New ARRAY_A: ', number_format( ( hrtime( true ) - $t ) / 1e9, 5 ).'s', "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 35
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 35
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 35
2 jumps found. (Code = 77) Position 1 = 39, Position 2 = 46
Branch analysis from position: 39
2 jumps found. (Code = 78) Position 1 = 40, Position 2 = 46
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 46
2 jumps found. (Code = 77) Position 1 = 55, Position 2 = 74
Branch analysis from position: 55
2 jumps found. (Code = 78) Position 1 = 56, Position 2 = 74
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 68
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 74
2 jumps found. (Code = 43) Position 1 = 96, Position 2 = 110
Branch analysis from position: 96
2 jumps found. (Code = 77) Position 1 = 98, Position 2 = 108
Branch analysis from position: 98
2 jumps found. (Code = 78) Position 1 = 99, Position 2 = 108
Branch analysis from position: 99
1 jumps found. (Code = 42) Position 1 = 98
Branch analysis from position: 98
Branch analysis from position: 108
1 jumps found. (Code = 42) Position 1 = 120
Branch analysis from position: 120
2 jumps found. (Code = 77) Position 1 = 141, Position 2 = 160
Branch analysis from position: 141
2 jumps found. (Code = 78) Position 1 = 142, Position 2 = 160
Branch analysis from position: 142
2 jumps found. (Code = 43) Position 1 = 145, Position 2 = 154
Branch analysis from position: 145
1 jumps found. (Code = 42) Position 1 = 159
Branch analysis from position: 159
1 jumps found. (Code = 42) Position 1 = 141
Branch analysis from position: 141
Branch analysis from position: 154
1 jumps found. (Code = 42) Position 1 = 141
Branch analysis from position: 141
Branch analysis from position: 160
2 jumps found. (Code = 43) Position 1 = 182, Position 2 = 196
Branch analysis from position: 182
2 jumps found. (Code = 77) Position 1 = 184, Position 2 = 194
Branch analysis from position: 184
2 jumps found. (Code = 78) Position 1 = 185, Position 2 = 194
Branch analysis from position: 185
1 jumps found. (Code = 42) Position 1 = 184
Branch analysis from position: 184
Branch analysis from position: 194
1 jumps found. (Code = 42) Position 1 = 206
Branch analysis from position: 206
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 194
Branch analysis from position: 196
2 jumps found. (Code = 77) Position 1 = 198, Position 2 = 205
Branch analysis from position: 198
2 jumps found. (Code = 78) Position 1 = 199, Position 2 = 205
Branch analysis from position: 199
1 jumps found. (Code = 42) Position 1 = 198
Branch analysis from position: 198
Branch analysis from position: 205
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 205
Branch analysis from position: 160
Branch analysis from position: 108
Branch analysis from position: 110
2 jumps found. (Code = 77) Position 1 = 112, Position 2 = 119
Branch analysis from position: 112
2 jumps found. (Code = 78) Position 1 = 113, Position 2 = 119
Branch analysis from position: 113
1 jumps found. (Code = 42) Position 1 = 112
Branch analysis from position: 112
Branch analysis from position: 119
2 jumps found. (Code = 77) Position 1 = 141, Position 2 = 160
Branch analysis from position: 141
Branch analysis from position: 160
Branch analysis from position: 119
Branch analysis from position: 74
Branch analysis from position: 46
Branch analysis from position: 35
filename:       /in/KvpIR
function name:  (null)
number of ops:  220
compiled vars:  !0 = $last_result, !1 = $output, !2 = $new_array, !3 = $row, !4 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'array_fill'
          1        SEND_VAL                                                 0
          2        SEND_VAL                                                 2000
    5     3        INIT_ARRAY                                       ~5      'hello_who', 'meta_key'
    6     4        INIT_FCALL                                               'str_repeat'
          5        SEND_VAL                                                 'World+and+WordPress+'
          6        SEND_VAL                                                 20
          7        DO_ICALL                                         $6      
          8        ADD_ARRAY_ELEMENT                                ~5      $6, 'meta_value'
          9        CAST                                          8  ~7      ~5
         10        SEND_VAL                                                 ~7
    4    11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !0, $8
    9    13        DECLARE_CONST                                            'ARRAY_N', 0
   10    14        ASSIGN                                                   !1, 0
   13    15        INIT_FCALL                                               'number_format'
         16        INIT_FCALL                                               'hrtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $11     
         19        DIV                                              ~12     $11, 1.0e+9
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                                 
   14    22        ASSIGN                                                   !2, <array>
   15    23        CAST                                          7  ~15     !0
         24      > FE_RESET_R                                       $16     ~15, ->35
         25    > > FE_FETCH_R                                               $16, !3, ->35
   17    26    >   INIT_FCALL                                               'array_values'
         27        INIT_FCALL                                               'get_object_vars'
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                         $18     
         30        SEND_VAR                                                 $18
         31        DO_ICALL                                         $19     
         32        ASSIGN_DIM                                               !2
         33        OP_DATA                                                  $19
   15    34      > JMP                                                      ->25
         35    >   FE_FREE                                                  $16
   19    36        ASSIGN                                                   !2, <array>
   20    37        CAST                                          7  ~21     !0
         38      > FE_RESET_R                                       $22     ~21, ->46
         39    > > FE_FETCH_R                                               $22, !3, ->46
   22    40    >   INIT_FCALL                                               'get_object_vars'
         41        SEND_VAR                                                 !3
         42        DO_ICALL                                         $24     
         43        ASSIGN_DIM                                               !2
         44        OP_DATA                                                  $24
   20    45      > JMP                                                      ->39
         46    >   FE_FREE                                                  $22
   24    47        ASSIGN                                                   !2, <array>
   28    48        ASSIGN                                                   !2, <array>
   29    49        INIT_FCALL                                               'hrtime'
         50        SEND_VAL                                                 <true>
         51        DO_ICALL                                         $27     
         52        ASSIGN                                                   !4, $27
   30    53        CAST                                          7  ~29     !0
         54      > FE_RESET_R                                       $30     ~29, ->74
         55    > > FE_FETCH_R                                               $30, !3, ->74
   31    56    >   FETCH_CONSTANT                                   ~31     'ARRAY_N'
         57        IS_IDENTICAL                                             !1, ~31
         58      > JMPZ                                                     ~32, ->68
   33    59    >   INIT_FCALL                                               'array_values'
         60        INIT_FCALL                                               'get_object_vars'
         61        SEND_VAR                                                 !3
         62        DO_ICALL                                         $34     
         63        SEND_VAR                                                 $34
         64        DO_ICALL                                         $35     
         65        ASSIGN_DIM                                               !2
         66        OP_DATA                                                  $35
   31    67      > JMP                                                      ->73
   36    68    >   INIT_FCALL                                               'get_object_vars'
         69        SEND_VAR                                                 !3
         70        DO_ICALL                                         $37     
         71        ASSIGN_DIM                                               !2
         72        OP_DATA                                                  $37
   30    73    > > JMP                                                      ->55
         74    >   FE_FREE                                                  $30
   39    75        ECHO                                                     'Old+ARRAY_N%3A+'
         76        INIT_FCALL                                               'number_format'
         77        INIT_FCALL                                               'hrtime'
         78        SEND_VAL                                                 <true>
         79        DO_ICALL                                         $38     
         80        SUB                                              ~39     $38, !4
         81        DIV                                              ~40     ~39, 1.0e+9
         82        SEND_VAL                                                 ~40
         83        SEND_VAL                                                 5
         84        DO_ICALL                                         $41     
         85        CONCAT                                           ~42     $41, 's'
         86        ECHO                                                     ~42
         87        ECHO                                                     '%0A'
   41    88        ASSIGN                                                   !2, <array>
   42    89        INIT_FCALL                                               'hrtime'
         90        SEND_VAL                                                 <true>
         91        DO_ICALL                                         $44     
         92        ASSIGN                                                   !4, $44
   43    93        FETCH_CONSTANT                                   ~46     'ARRAY_N'
         94        IS_IDENTICAL                                             !1, ~46
         95      > JMPZ                                                     ~47, ->110
   44    96    >   CAST                                          7  ~48     !0
         97      > FE_RESET_R                                       $49     ~48, ->108
         98    > > FE_FETCH_R                                               $49, !3, ->108
   46    99    >   INIT_FCALL                                               'array_values'
        100        INIT_FCALL                                               'get_object_vars'
        101        SEND_VAR                                                 !3
        102        DO_ICALL                                         $51     
        103        SEND_VAR                                                 $51
        104        DO_ICALL                                         $52     
        105        ASSIGN_DIM                                               !2
        106        OP_DATA                                                  $52
   44   107      > JMP                                                      ->98
        108    >   FE_FREE                                                  $49
   43   109      > JMP                                                      ->120
   49   110    >   CAST                                          7  ~53     !0
        111      > FE_RESET_R                                       $54     ~53, ->119
        112    > > FE_FETCH_R                                               $54, !3, ->119
   51   113    >   INIT_FCALL                                               'get_object_vars'
        114        SEND_VAR                                                 !3
        115        DO_ICALL                                         $56     
        116        ASSIGN_DIM                                               !2
        117        OP_DATA                                                  $56
   49   118      > JMP                                                      ->112
        119    >   FE_FREE                                                  $54
   54   120    >   ECHO                                                     'New+ARRAY_N%3A+'
        121        INIT_FCALL                                               'number_format'
        122        INIT_FCALL                                               'hrtime'
        123        SEND_VAL                                                 <true>
        124        DO_ICALL                                         $57     
        125        SUB                                              ~58     $57, !4
        126        DIV                                              ~59     ~58, 1.0e+9
        127        SEND_VAL                                                 ~59
        128        SEND_VAL                                                 5
        129        DO_ICALL                                         $60     
        130        CONCAT                                           ~61     $60, 's'
        131        ECHO                                                     ~61
        132        ECHO                                                     '%0A'
   57   133        ASSIGN                                                   !1, 1
   59   134        ASSIGN                                                   !2, <array>
   60   135        INIT_FCALL                                               'hrtime'
        136        SEND_VAL                                                 <true>
        137        DO_ICALL                                         $64     
        138        ASSIGN                                                   !4, $64
   61   139        CAST                                          7  ~66     !0
        140      > FE_RESET_R                                       $67     ~66, ->160
        141    > > FE_FETCH_R                                               $67, !3, ->160
   62   142    >   FETCH_CONSTANT                                   ~68     'ARRAY_N'
        143        IS_IDENTICAL                                             !1, ~68
        144      > JMPZ                                                     ~69, ->154
   64   145    >   INIT_FCALL                                               'array_values'
        146        INIT_FCALL                                               'get_object_vars'
        147        SEND_VAR                                                 !3
        148        DO_ICALL                                         $71     
        149        SEND_VAR                                                 $71
        150        DO_ICALL                                         $72     
        151        ASSIGN_DIM                                               !2
        152        OP_DATA                                                  $72
   62   153      > JMP                                                      ->159
   67   154    >   INIT_FCALL                                               'get_object_vars'
        155        SEND_VAR                                                 !3
        156        DO_ICALL                                         $74     
        157        ASSIGN_DIM                                               !2
        158        OP_DATA                                                  $74
   61   159    > > JMP                                                      ->141
        160    >   FE_FREE                                                  $67
   70   161        ECHO                                                     'Old+ARRAY_A%3A+'
        162        INIT_FCALL                                               'number_format'
        163        INIT_FCALL                                               'hrtime'
        164        SEND_VAL                                                 <true>
        165        DO_ICALL                                         $75     
        166        SUB                                              ~76     $75, !4
        167        DIV                                              ~77     ~76, 1.0e+9
        168        SEND_VAL                                                 ~77
        169        SEND_VAL                                                 5
        170        DO_ICALL                                         $78     
        171        CONCAT                                           ~79     $78, 's'
        172        ECHO                                                     ~79
        173        ECHO                                                     '%0A'
   72   174        ASSIGN                                                   !2, <array>
   73   175        INIT_FCALL                                               'hrtime'
        176        SEND_VAL                                                 <true>
        177        DO_ICALL                                         $81     
        178        ASSIGN                                                   !4, $81
   74   179        FETCH_CONSTANT                                   ~83     'ARRAY_N'
        180        IS_IDENTICAL                                             !1, ~83
        181      > JMPZ                                                     ~84, ->196
   75   182    >   CAST                                          7  ~85     !0
        183      > FE_RESET_R                                       $86     ~85, ->194
        184    > > FE_FETCH_R                                               $86, !3, ->194
   77   185    >   INIT_FCALL                                               'array_values'
        186        INIT_FCALL                                               'get_object_vars'
        187        SEND_VAR                                                 !3
        188        DO_ICALL                                         $88     
        189        SEND_VAR                                                 $88
        190        DO_ICALL                                         $89     
        191        ASSIGN_DIM                                               !2
        192        OP_DATA                                                  $89
   75   193      > JMP                                                      ->184
        194    >   FE_FREE                                                  $86
   74   195      > JMP                                                      ->206
   80   196    >   CAST                                          7  ~90     !0
        197      > FE_RESET_R                                       $91     ~90, ->205
        198    > > FE_FETCH_R                                               $91, !3, ->205
   82   199    >   INIT_FCALL                                               'get_object_vars'
        200        SEND_VAR                                                 !3
        201        DO_ICALL                                         $93     
        202        ASSIGN_DIM                                               !2
        203        OP_DATA                                                  $93
   80   204      > JMP                                                      ->198
        205    >   FE_FREE                                                  $91
   85   206    >   ECHO                                                     'New+ARRAY_A%3A+'
        207        INIT_FCALL                                               'number_format'
        208        INIT_FCALL                                               'hrtime'
        209        SEND_VAL                                                 <true>
        210        DO_ICALL                                         $94     
        211        SUB                                              ~95     $94, !4
        212        DIV                                              ~96     ~95, 1.0e+9
        213        SEND_VAL                                                 ~96
        214        SEND_VAL                                                 5
        215        DO_ICALL                                         $97     
        216        CONCAT                                           ~98     $97, 's'
        217        ECHO                                                     ~98
        218        ECHO                                                     '%0A'
        219      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.65 ms | 1486 KiB | 19 Q