3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @return Generator */ function test() { echo "Preparing generator.", PHP_EOL; $start = microtime(true); $first = (yield Async::call("file_get_contents", array("http://www.php.net"))); echo "Receiving first result: ", number_format((microtime(true) - $start) * 1e3, 2), 'ms', PHP_EOL; $second = (yield Async::call("file_get_contents", array("http://www.alpari.ru"))); echo "Receiving second result: ", number_format((microtime(true) - $start) * 1e3, 2), 'ms', PHP_EOL; echo "Asynchronous result received: ", strlen((string) $first), ' and ', strlen((string) $second), 'bytes', PHP_EOL; echo "Total: ", number_format((microtime(true) - $start) * 1e3, 2), 'ms', PHP_EOL; }; echo "<pre>"; $future = test();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hOKu9
function name:  (null)
number of ops:  5
compiled vars:  !0 = $future
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ECHO                                                     '%3Cpre%3E'
   18     1        INIT_FCALL                                               'test'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
          4      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/hOKu9
function name:  test
number of ops:  69
compiled vars:  !0 = $start, !1 = $first, !2 = $second
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   GENERATOR_CREATE                                         
    7     1        ECHO                                                     'Preparing+generator.'
          2        ECHO                                                     '%0A'
    8     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
    9     7        INIT_STATIC_METHOD_CALL                                  'Async', 'call'
          8        SEND_VAL_EX                                              'file_get_contents'
          9        SEND_VAL_EX                                              <array>
         10        DO_FCALL                                      0  $5      
         11        YIELD                                            $6      $5
         12        ASSIGN                                                   !1, $6
   10    13        ECHO                                                     'Receiving+first+result%3A+'
         14        INIT_FCALL                                               'number_format'
         15        INIT_FCALL                                               'microtime'
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $8      
         18        SUB                                              ~9      $8, !0
         19        MUL                                              ~10     ~9, 1000
         20        SEND_VAL                                                 ~10
         21        SEND_VAL                                                 2
         22        DO_ICALL                                         $11     
         23        ECHO                                                     $11
         24        ECHO                                                     'ms'
         25        ECHO                                                     '%0A'
   11    26        INIT_STATIC_METHOD_CALL                                  'Async', 'call'
         27        SEND_VAL_EX                                              'file_get_contents'
         28        SEND_VAL_EX                                              <array>
         29        DO_FCALL                                      0  $12     
         30        YIELD                                            $13     $12
         31        ASSIGN                                                   !2, $13
   12    32        ECHO                                                     'Receiving+second+result%3A+'
         33        INIT_FCALL                                               'number_format'
         34        INIT_FCALL                                               'microtime'
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $15     
         37        SUB                                              ~16     $15, !0
         38        MUL                                              ~17     ~16, 1000
         39        SEND_VAL                                                 ~17
         40        SEND_VAL                                                 2
         41        DO_ICALL                                         $18     
         42        ECHO                                                     $18
         43        ECHO                                                     'ms'
         44        ECHO                                                     '%0A'
   13    45        ECHO                                                     'Asynchronous+result+received%3A+'
         46        CAST                                          6  ~19     !1
         47        STRLEN                                           ~20     ~19
         48        ECHO                                                     ~20
         49        ECHO                                                     '+and+'
         50        CAST                                          6  ~21     !2
         51        STRLEN                                           ~22     ~21
         52        ECHO                                                     ~22
         53        ECHO                                                     'bytes'
         54        ECHO                                                     '%0A'
   14    55        ECHO                                                     'Total%3A+'
         56        INIT_FCALL                                               'number_format'
         57        INIT_FCALL                                               'microtime'
         58        SEND_VAL                                                 <true>
         59        DO_ICALL                                         $23     
         60        SUB                                              ~24     $23, !0
         61        MUL                                              ~25     ~24, 1000
         62        SEND_VAL                                                 ~25
         63        SEND_VAL                                                 2
         64        DO_ICALL                                         $26     
         65        ECHO                                                     $26
         66        ECHO                                                     'ms'
         67        ECHO                                                     '%0A'
   15    68      > GENERATOR_RETURN                                         

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.27 ms | 1403 KiB | 18 Q