3v4l.org

run code in 300+ PHP versions simultaneously
<?php function measture_duration(callable $callback) { $start = microtime(true); call_user_func($callback); $duration = microtime(true) - $start; printf("Duration: %s\n\n", number_format($duration, 6)); } function timestamp_lowest(array $array) { return min(array_column($array, 'ts')); } function timestamp_lowest2(array $array) { $values = array_column($array, 'ts'); $values = array_slice($values, 1); return min($values); } $timezone = new DateTimeZone('Europe/Berlin'); $duration = measture_duration(function() use($timezone) { printf("Default Value\n"); $result = $timezone->getTransitions(); $lowest = timestamp_lowest($result); printf("Lowest timestamp: %s (%s)\n", $lowest, date('Y-m-d', $lowest)); $lowest2 = timestamp_lowest2($result); printf("Lowest timestamp2: %s (%s)\n", $lowest2, date('Y-m-d', $lowest2)); }); $duration = measture_duration(function() use($timezone) { $timestamp = 0; printf("Timestamp for %s\n", date('Y-m-d H:i:s', $timestamp)); $result = $timezone->getTransitions($timestamp); $lowest = timestamp_lowest($result); printf("Lowest timestamp: %s (%s)\n", $lowest, date('Y-m-d', $lowest)); }); $duration = measture_duration(function() use($timezone) { $timestamp = -62135596800; printf("Timestamp for %s\n", date('Y-m-d H:i:s', $timestamp)); $result = $timezone->getTransitions($timestamp); $lowest = timestamp_lowest($result); printf("Lowest timestamp: %s (%s)\n", $lowest, date('Y-m-d', $lowest)); });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8osB8
function name:  (null)
number of ops:  23
compiled vars:  !0 = $timezone, !1 = $duration
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $2      'DateTimeZone'
          1        SEND_VAL_EX                                              'Europe%2FBerlin'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   22     4        INIT_FCALL                                               'measture_duration'
          5        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          6        BIND_LEXICAL                                             ~5, !0
   30     7        SEND_VAL                                                 ~5
   22     8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !1, $6
   32    10        INIT_FCALL                                               'measture_duration'
         11        DECLARE_LAMBDA_FUNCTION                          ~8      [1]
         12        BIND_LEXICAL                                             ~8, !0
   38    13        SEND_VAL                                                 ~8
   32    14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !1, $9
   40    16        INIT_FCALL                                               'measture_duration'
         17        DECLARE_LAMBDA_FUNCTION                          ~11     [2]
         18        BIND_LEXICAL                                             ~11, !0
   46    19        SEND_VAL                                                 ~11
   40    20        DO_FCALL                                      0  $12     
         21        ASSIGN                                                   !1, $12
   46    22      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8osB8
function name:  {closure}
number of ops:  34
compiled vars:  !0 = $timezone, !1 = $result, !2 = $lowest, !3 = $lowest2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   BIND_STATIC                                              !0
   23     1        INIT_FCALL                                               'printf'
          2        SEND_VAL                                                 'Default+Value%0A'
          3        DO_ICALL                                                 
   24     4        INIT_METHOD_CALL                                         !0, 'getTransitions'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   25     7        INIT_FCALL                                               'timestamp_lowest'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $7      
         10        ASSIGN                                                   !2, $7
   26    11        INIT_FCALL                                               'printf'
         12        SEND_VAL                                                 'Lowest+timestamp%3A+%25s+%28%25s%29%0A'
         13        SEND_VAR                                                 !2
         14        INIT_FCALL                                               'date'
         15        SEND_VAL                                                 'Y-m-d'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
   28    20        INIT_FCALL                                               'timestamp_lowest2'
         21        SEND_VAR                                                 !1
         22        DO_FCALL                                      0  $11     
         23        ASSIGN                                                   !3, $11
   29    24        INIT_FCALL                                               'printf'
         25        SEND_VAL                                                 'Lowest+timestamp2%3A+%25s+%28%25s%29%0A'
         26        SEND_VAR                                                 !3
         27        INIT_FCALL                                               'date'
         28        SEND_VAL                                                 'Y-m-d'
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                         $13     
         31        SEND_VAR                                                 $13
         32        DO_ICALL                                                 
   30    33      > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8osB8
function name:  {closure}
number of ops:  28
compiled vars:  !0 = $timezone, !1 = $timestamp, !2 = $result, !3 = $lowest
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   BIND_STATIC                                              !0
   33     1        ASSIGN                                                   !1, 0
   34     2        INIT_FCALL                                               'printf'
          3        SEND_VAL                                                 'Timestamp+for+%25s%0A'
          4        INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $5      
          8        SEND_VAR                                                 $5
          9        DO_ICALL                                                 
   35    10        INIT_METHOD_CALL                                         !0, 'getTransitions'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $7      
         13        ASSIGN                                                   !2, $7
   36    14        INIT_FCALL                                               'timestamp_lowest'
         15        SEND_VAR                                                 !2
         16        DO_FCALL                                      0  $9      
         17        ASSIGN                                                   !3, $9
   37    18        INIT_FCALL                                               'printf'
         19        SEND_VAL                                                 'Lowest+timestamp%3A+%25s+%28%25s%29%0A'
         20        SEND_VAR                                                 !3
         21        INIT_FCALL                                               'date'
         22        SEND_VAL                                                 'Y-m-d'
         23        SEND_VAR                                                 !3
         24        DO_ICALL                                         $11     
         25        SEND_VAR                                                 $11
         26        DO_ICALL                                                 
   38    27      > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8osB8
function name:  {closure}
number of ops:  28
compiled vars:  !0 = $timezone, !1 = $timestamp, !2 = $result, !3 = $lowest
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   BIND_STATIC                                              !0
   41     1        ASSIGN                                                   !1, -62135596800
   42     2        INIT_FCALL                                               'printf'
          3        SEND_VAL                                                 'Timestamp+for+%25s%0A'
          4        INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $5      
          8        SEND_VAR                                                 $5
          9        DO_ICALL                                                 
   43    10        INIT_METHOD_CALL                                         !0, 'getTransitions'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $7      
         13        ASSIGN                                                   !2, $7
   44    14        INIT_FCALL                                               'timestamp_lowest'
         15        SEND_VAR                                                 !2
         16        DO_FCALL                                      0  $9      
         17        ASSIGN                                                   !3, $9
   45    18        INIT_FCALL                                               'printf'
         19        SEND_VAL                                                 'Lowest+timestamp%3A+%25s+%28%25s%29%0A'
         20        SEND_VAR                                                 !3
         21        INIT_FCALL                                               'date'
         22        SEND_VAL                                                 'Y-m-d'
         23        SEND_VAR                                                 !3
         24        DO_ICALL                                         $11     
         25        SEND_VAR                                                 $11
         26        DO_ICALL                                                 
   46    27      > RETURN                                                   null

End of Dynamic Function 2

Function measture_duration:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8osB8
function name:  measture_duration
number of ops:  21
compiled vars:  !0 = $callback, !1 = $start, !2 = $duration
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
    5     5        INIT_USER_CALL                                0          'call_user_func', !0
          6        DO_FCALL                                      0          
    6     7        INIT_FCALL                                               'microtime'
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $6      
         10        SUB                                              ~7      $6, !1
         11        ASSIGN                                                   !2, ~7
    7    12        INIT_FCALL                                               'printf'
         13        SEND_VAL                                                 'Duration%3A+%25s%0A%0A'
         14        INIT_FCALL                                               'number_format'
         15        SEND_VAR                                                 !2
         16        SEND_VAL                                                 6
         17        DO_ICALL                                         $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
    8    20      > RETURN                                                   null

End of function measture_duration

Function timestamp_lowest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8osB8
function name:  timestamp_lowest
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'min'
          2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'ts'
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        DO_ICALL                                         $2      
          8      > RETURN                                                   $2
   12     9*     > RETURN                                                   null

End of function timestamp_lowest

Function timestamp_lowest2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8osB8
function name:  timestamp_lowest2
number of ops:  16
compiled vars:  !0 = $array, !1 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'array_column'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'ts'
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !1, $2
   16     6        INIT_FCALL                                               'array_slice'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $4      
         10        ASSIGN                                                   !1, $4
   17    11        INIT_FCALL                                               'min'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $6      
         14      > RETURN                                                   $6
   18    15*     > RETURN                                                   null

End of function timestamp_lowest2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.42 ms | 1028 KiB | 27 Q