3v4l.org

run code in 300+ PHP versions simultaneously
<?php $iterations = 1_000_000; class Result { } benchmark('Result object', fn() => new Result()); benchmark('Exceptions', fn() => throw new \RuntimeException()); function benchmark(string $label, \Closure $closure) { global $iterations; $sT = microtime(true); for ($i = 0; $i < $iterations; $i ++) { try { $closure(); } catch (\Exception $e) { } } echo $label . ' : ' . (microtime(true) - $sT) . 's' . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OLCMG
function name:  (null)
number of ops:  12
compiled vars:  !0 = $iterations
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 1000000
    9     1        INIT_FCALL_BY_NAME                                       'benchmark'
          2        SEND_VAL_EX                                              'Result+object'
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FOLCMG%3A9%240'
          4        SEND_VAL_EX                                              ~2
          5        DO_FCALL                                      0          
   10     6        INIT_FCALL_BY_NAME                                       'benchmark'
          7        SEND_VAL_EX                                              'Exceptions'
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FOLCMG%3A10%241'
          9        SEND_VAL_EX                                              ~4
         10        DO_FCALL                                      0          
   24    11      > RETURN                                                   1

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

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

Function %00%7Bclosure%7D%2Fin%2FOLCMG%3A10%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/OLCMG
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $0      'RuntimeException'
          1        DO_FCALL                                      0          
          2      > THROW                                         1          $0
          3*       RETURN                                                   <true>
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FOLCMG%3A10%241

Function benchmark:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 9
Branch analysis from position: 16
Branch analysis from position: 9
Found catch point at position: 12
Branch analysis from position: 12
2 jumps found. (Code = 107) Position 1 = 13, Position 2 = -2
Branch analysis from position: 13
filename:       /in/OLCMG
function name:  benchmark
number of ops:  26
compiled vars:  !0 = $label, !1 = $closure, !2 = $iterations, !3 = $sT, !4 = $i, !5 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        BIND_GLOBAL                                              !2, 'iterations'
   15     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !3, $6
   16     7        ASSIGN                                                   !4, 0
          8      > JMP                                                      ->14
   18     9    >   INIT_DYNAMIC_CALL                                        !1
         10        DO_FCALL                                      0          
         11      > JMP                                                      ->13
   19    12  E > > CATCH                                       last         'Exception'
   16    13    >   PRE_INC                                                  !4
         14    >   IS_SMALLER                                               !4, !2
         15      > JMPNZ                                                    ~11, ->9
   23    16    >   CONCAT                                           ~12     !0, '+%3A+'
         17        INIT_FCALL                                               'microtime'
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                         $13     
         20        SUB                                              ~14     $13, !3
         21        CONCAT                                           ~15     ~12, ~14
         22        CONCAT                                           ~16     ~15, 's'
         23        CONCAT                                           ~17     ~16, '%0A'
         24        ECHO                                                     ~17
   24    25      > RETURN                                                   null

End of function benchmark

Class Result: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.69 ms | 1400 KiB | 15 Q