3v4l.org

run code in 300+ PHP versions simultaneously
<?php //https://github.com/php/php-src/blob/master/Zend/micro_bench.php function hallo() {} function hallo2() {} function simpleucall($n) { for ($i = 0; $i < $n; $i++) hallo(); } function simpleudcall($n) { for ($i = 0; $i < $n; $i++) hallo2(); } function simpleicall($n) { for ($i = 0; $i < $n; $i++) func_num_args(); } define('TEST', null); function read_const($n) { for ($i = 0; $i < $n; ++$i) $x = TEST; } function read_auto_global($n) { for ($i = 0; $i < $n; ++$i) $x = $_GET; } $g_var = 0; function read_global_var($n) { for ($i = 0; $i < $n; ++$i) $x = $GLOBALS['g_var']; } function read_hash($n) { $hash = array('test' => 0); for ($i = 0; $i < $n; ++$i) $x = $hash['test'];} function read_str_offset($n) { $str = "test"; for ($i = 0; $i < $n; ++$i) $x = $str[1]; } function ternary($n) { $val = array(0,1,2,3,4,5,6,7,8,9); $f = false; for ($i = 0; $i < $n; ++$i) $x = $f ? null : $val; } function ternary2($n) { $f = false; $j = 0; for ($i = 0; $i < $n; ++$i) $x = $f ? $f : $j + 1; } /*****/ function getmicrotime() { $t = gettimeofday(); return ($t['sec'] + $t['usec'] / 1000000);} const N = 50000; simpleucall(N); simpleudcall(N); simpleicall(N); read_const(N); read_auto_global(N); read_global_var(N); read_hash(N); read_str_offset(N); ternary(N); ternary2(N);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PIDX8
function name:  (null)
number of ops:  47
compiled vars:  !0 = $g_var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'TEST'
          2        SEND_VAL                                                 null
          3        DO_ICALL                                                 
   17     4        ASSIGN                                                   !0, 0
   29     5        DECLARE_CONST                                            'N', 50000
   31     6        INIT_FCALL                                               'simpleucall'
          7        FETCH_CONSTANT                                   ~3      'N'
          8        SEND_VAL                                                 ~3
          9        DO_FCALL                                      0          
   32    10        INIT_FCALL                                               'simpleudcall'
         11        FETCH_CONSTANT                                   ~5      'N'
         12        SEND_VAL                                                 ~5
         13        DO_FCALL                                      0          
   33    14        INIT_FCALL                                               'simpleicall'
         15        FETCH_CONSTANT                                   ~7      'N'
         16        SEND_VAL                                                 ~7
         17        DO_FCALL                                      0          
   34    18        INIT_FCALL                                               'read_const'
         19        FETCH_CONSTANT                                   ~9      'N'
         20        SEND_VAL                                                 ~9
         21        DO_FCALL                                      0          
   35    22        INIT_FCALL                                               'read_auto_global'
         23        FETCH_CONSTANT                                   ~11     'N'
         24        SEND_VAL                                                 ~11
         25        DO_FCALL                                      0          
   36    26        INIT_FCALL                                               'read_global_var'
         27        FETCH_CONSTANT                                   ~13     'N'
         28        SEND_VAL                                                 ~13
         29        DO_FCALL                                      0          
   37    30        INIT_FCALL                                               'read_hash'
         31        FETCH_CONSTANT                                   ~15     'N'
         32        SEND_VAL                                                 ~15
         33        DO_FCALL                                      0          
   38    34        INIT_FCALL                                               'read_str_offset'
         35        FETCH_CONSTANT                                   ~17     'N'
         36        SEND_VAL                                                 ~17
         37        DO_FCALL                                      0          
   39    38        INIT_FCALL                                               'ternary'
         39        FETCH_CONSTANT                                   ~19     'N'
         40        SEND_VAL                                                 ~19
         41        DO_FCALL                                      0          
   40    42        INIT_FCALL                                               'ternary2'
         43        FETCH_CONSTANT                                   ~21     'N'
         44        SEND_VAL                                                 ~21
         45        DO_FCALL                                      0          
         46      > RETURN                                                   1

Function hallo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PIDX8
function name:  hallo
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E > > RETURN                                                   null

End of function hallo

Function hallo2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PIDX8
function name:  hallo2
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   null

End of function hallo2

Function simpleucall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
Branch analysis from position: 3
filename:       /in/PIDX8
function name:  simpleucall
number of ops:  9
compiled vars:  !0 = $n, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->6
          3    >   INIT_FCALL                                               'hallo'
          4        DO_FCALL                                      0          
          5        PRE_INC                                                  !1
          6    >   IS_SMALLER                                               !1, !0
          7      > JMPNZ                                                    ~5, ->3
          8    > > RETURN                                                   null

End of function simpleucall

Function simpleudcall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
Branch analysis from position: 3
filename:       /in/PIDX8
function name:  simpleudcall
number of ops:  9
compiled vars:  !0 = $n, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->6
          3    >   INIT_FCALL                                               'hallo2'
          4        DO_FCALL                                      0          
          5        PRE_INC                                                  !1
          6    >   IS_SMALLER                                               !1, !0
          7      > JMPNZ                                                    ~5, ->3
          8    > > RETURN                                                   null

End of function simpleudcall

Function simpleicall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
Branch analysis from position: 3
filename:       /in/PIDX8
function name:  simpleicall
number of ops:  9
compiled vars:  !0 = $n, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->6
          3    >   FUNC_NUM_ARGS                                    ~3      
          4        FREE                                                     ~3
          5        PRE_INC                                                  !1
          6    >   IS_SMALLER                                               !1, !0
          7      > JMPNZ                                                    ~5, ->3
          8    > > RETURN                                                   null

End of function simpleicall

Function read_const:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
Branch analysis from position: 3
filename:       /in/PIDX8
function name:  read_const
number of ops:  9
compiled vars:  !0 = $n, !1 = $i, !2 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->6
          3    >   FETCH_CONSTANT                                   ~4      'TEST'
          4        ASSIGN                                                   !2, ~4
          5        PRE_INC                                                  !1
          6    >   IS_SMALLER                                               !1, !0
          7      > JMPNZ                                                    ~7, ->3
          8    > > RETURN                                                   null

End of function read_const

Function read_auto_global:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
Branch analysis from position: 3
filename:       /in/PIDX8
function name:  read_auto_global
number of ops:  9
compiled vars:  !0 = $n, !1 = $i, !2 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->6
          3    >   FETCH_R                      global              ~4      '_GET'
          4        ASSIGN                                                   !2, ~4
          5        PRE_INC                                                  !1
          6    >   IS_SMALLER                                               !1, !0
          7      > JMPNZ                                                    ~7, ->3
          8    > > RETURN                                                   null

End of function read_auto_global

Function read_global_var:
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
1 jumps found. (Code = 62) Position 1 = -2
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/PIDX8
function name:  read_global_var
number of ops:  10
compiled vars:  !0 = $n, !1 = $i, !2 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->7
          3    >   FETCH_R                      global              ~4      'GLOBALS'
          4        FETCH_DIM_R                                      ~5      ~4, 'g_var'
          5        ASSIGN                                                   !2, ~5
          6        PRE_INC                                                  !1
          7    >   IS_SMALLER                                               !1, !0
          8      > JMPNZ                                                    ~8, ->3
          9    > > RETURN                                                   null

End of function read_global_var

Function read_hash:
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 = 4
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 4
Branch analysis from position: 9
Branch analysis from position: 4
filename:       /in/PIDX8
function name:  read_hash
number of ops:  10
compiled vars:  !0 = $n, !1 = $hash, !2 = $i, !3 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, <array>
          2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->7
          4    >   FETCH_DIM_R                                      ~6      !1, 'test'
          5        ASSIGN                                                   !3, ~6
          6        PRE_INC                                                  !2
          7    >   IS_SMALLER                                               !2, !0
          8      > JMPNZ                                                    ~9, ->4
          9    > > RETURN                                                   null

End of function read_hash

Function read_str_offset:
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 = 4
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 4
Branch analysis from position: 9
Branch analysis from position: 4
filename:       /in/PIDX8
function name:  read_str_offset
number of ops:  10
compiled vars:  !0 = $n, !1 = $str, !2 = $i, !3 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, 'test'
          2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->7
          4    >   FETCH_DIM_R                                      ~6      !1, 1
          5        ASSIGN                                                   !3, ~6
          6        PRE_INC                                                  !2
          7    >   IS_SMALLER                                               !2, !0
          8      > JMPNZ                                                    ~9, ->4
          9    > > RETURN                                                   null

End of function read_str_offset

Function ternary:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 5
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 5
Branch analysis from position: 13
Branch analysis from position: 5
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 5
Branch analysis from position: 13
Branch analysis from position: 5
filename:       /in/PIDX8
function name:  ternary
number of ops:  14
compiled vars:  !0 = $n, !1 = $val, !2 = $f, !3 = $i, !4 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, <array>
          2        ASSIGN                                                   !2, <false>
          3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->11
          5    > > JMPZ                                                     !2, ->8
          6    >   QM_ASSIGN                                        ~8      null
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~8      !1
          9    >   ASSIGN                                                   !4, ~8
         10        PRE_INC                                                  !3
         11    >   IS_SMALLER                                               !3, !0
         12      > JMPNZ                                                    ~11, ->5
         13    > > RETURN                                                   null

End of function ternary

Function ternary2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
Branch analysis from position: 5
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 5
Branch analysis from position: 14
Branch analysis from position: 5
filename:       /in/PIDX8
function name:  ternary2
number of ops:  15
compiled vars:  !0 = $n, !1 = $f, !2 = $j, !3 = $i, !4 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        ASSIGN                                                   !1, <false>
          2        ASSIGN                                                   !2, 0
          3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->12
          5    > > JMPZ                                                     !1, ->8
          6    >   QM_ASSIGN                                        ~8      !1
          7      > JMP                                                      ->10
          8    >   ADD                                              ~9      !2, 1
          9        QM_ASSIGN                                        ~8      ~9
         10    >   ASSIGN                                                   !4, ~8
         11        PRE_INC                                                  !3
         12    >   IS_SMALLER                                               !3, !0
         13      > JMPNZ                                                    ~12, ->5
         14    > > RETURN                                                   null

End of function ternary2

Function getmicrotime:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PIDX8
function name:  getmicrotime
number of ops:  9
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'gettimeofday'
          1        DO_ICALL                                         $1      
          2        ASSIGN                                                   !0, $1
          3        FETCH_DIM_R                                      ~3      !0, 'sec'
          4        FETCH_DIM_R                                      ~4      !0, 'usec'
          5        DIV                                              ~5      ~4, 1000000
          6        ADD                                              ~6      ~3, ~5
          7      > RETURN                                                   ~6
          8*     > RETURN                                                   null

End of function getmicrotime

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.96 ms | 1410 KiB | 29 Q