3v4l.org

run code in 300+ PHP versions simultaneously
<?php function micro_parse($a) { $parts = explode(' ', $a); return [ (int)$parts[1], (int)substr($parts[0], 2, 6) ]; } function micro_diff($a, $b) { return [ $b[0] - $a[0], $b[1] - $a[1] ]; } function micro_fmt($a) { return sprintf('%d.%06d', $a[0], $a[1]); } $str = 'foobar'; $iter = 100000; $algos = ['md5', 'fnv1a32', 'fnv1a64']; foreach($algos as $algo) { $start = microtime(); for( $i=0; $i<$iter; $i++ ) { $h = hash($algo, $str); } $end = microtime(); printf("%8s: %s\n", $algo, micro_fmt(micro_diff(micro_parse($start), micro_parse($end)))); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 40
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 40
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 10
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 10
Branch analysis from position: 18
Branch analysis from position: 10
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/uKnIv
function name:  (null)
number of ops:  42
compiled vars:  !0 = $str, !1 = $iter, !2 = $algos, !3 = $algo, !4 = $start, !5 = $i, !6 = $h, !7 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, 'foobar'
   20     1        ASSIGN                                                   !1, 100000
   21     2        ASSIGN                                                   !2, <array>
   23     3      > FE_RESET_R                                       $11     !2, ->40
          4    > > FE_FETCH_R                                               $11, !3, ->40
   24     5    >   INIT_FCALL                                               'microtime'
          6        DO_ICALL                                         $12     
          7        ASSIGN                                                   !4, $12
   25     8        ASSIGN                                                   !5, 0
          9      > JMP                                                      ->16
   26    10    >   INIT_FCALL                                               'hash'
         11        SEND_VAR                                                 !3
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $15     
         14        ASSIGN                                                   !6, $15
   25    15        PRE_INC                                                  !5
         16    >   IS_SMALLER                                               !5, !1
         17      > JMPNZ                                                    ~18, ->10
   28    18    >   INIT_FCALL                                               'microtime'
         19        DO_ICALL                                         $19     
         20        ASSIGN                                                   !7, $19
   29    21        INIT_FCALL                                               'printf'
         22        SEND_VAL                                                 '%258s%3A+%25s%0A'
         23        SEND_VAR                                                 !3
         24        INIT_FCALL                                               'micro_fmt'
         25        INIT_FCALL                                               'micro_diff'
         26        INIT_FCALL                                               'micro_parse'
         27        SEND_VAR                                                 !4
         28        DO_FCALL                                      0  $21     
         29        SEND_VAR                                                 $21
         30        INIT_FCALL                                               'micro_parse'
         31        SEND_VAR                                                 !7
         32        DO_FCALL                                      0  $22     
         33        SEND_VAR                                                 $22
         34        DO_FCALL                                      0  $23     
         35        SEND_VAR                                                 $23
         36        DO_FCALL                                      0  $24     
         37        SEND_VAR                                                 $24
         38        DO_ICALL                                                 
   23    39      > JMP                                                      ->4
         40    >   FE_FREE                                                  $11
   30    41      > RETURN                                                   1

Function micro_parse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uKnIv
function name:  micro_parse
number of ops:  19
compiled vars:  !0 = $a, !1 = $parts
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !1, $2
    6     6        FETCH_DIM_R                                      ~4      !1, 1
          7        CAST                                          4  ~5      ~4
          8        INIT_ARRAY                                       ~6      ~5
    7     9        INIT_FCALL                                               'substr'
         10        FETCH_DIM_R                                      ~7      !1, 0
         11        SEND_VAL                                                 ~7
         12        SEND_VAL                                                 2
         13        SEND_VAL                                                 6
         14        DO_ICALL                                         $8      
         15        CAST                                          4  ~9      $8
         16        ADD_ARRAY_ELEMENT                                ~6      ~9
         17      > RETURN                                                   ~6
    9    18*     > RETURN                                                   null

End of function micro_parse

Function micro_diff:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uKnIv
function name:  micro_diff
number of ops:  12
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        FETCH_DIM_R                                      ~2      !1, 0
          3        FETCH_DIM_R                                      ~3      !0, 0
          4        SUB                                              ~4      ~2, ~3
          5        INIT_ARRAY                                       ~5      ~4
          6        FETCH_DIM_R                                      ~6      !1, 1
          7        FETCH_DIM_R                                      ~7      !0, 1
          8        SUB                                              ~8      ~6, ~7
          9        ADD_ARRAY_ELEMENT                                ~5      ~8
         10      > RETURN                                                   ~5
   13    11*     > RETURN                                                   null

End of function micro_diff

Function micro_fmt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uKnIv
function name:  micro_fmt
number of ops:  10
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'sprintf'
          2        SEND_VAL                                                 '%25d.%2506d'
          3        FETCH_DIM_R                                      ~1      !0, 0
          4        SEND_VAL                                                 ~1
          5        FETCH_DIM_R                                      ~2      !0, 1
          6        SEND_VAL                                                 ~2
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   17     9*     > RETURN                                                   null

End of function micro_fmt

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.8 ms | 1411 KiB | 29 Q