3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { function __construct($c) { $this->count = $c; } function getPrev() { return $this->prev; } function setPrev($pr) { $this->prev = $pr; } function getNext() { return $this->next; } function setNext($nxt) { $this->next = $nxt; } function shout($shout, $nth) { if ($shout < $nth) { return $shout + 1; } $this->getPrev()->setNext($this->getNext()); $this->getNext()->setPrev($this->getPrev()); return 1; } } class Chain { var $first; function __construct($size) { $last =null; for($i = 0; $i < $size ; $i++) { $current = new Person($i); if ($this->first == null) $this->first = $current; if ($last != null) { $last->setNext($current); $current->setPrev($last); } $last = $current; } $this->first->setPrev($last); $last->setNext($this->first); } function kill($nth) { $current = $this->first; $shout = 1; while($current->getNext() !== $current) { $shout = $current->shout($shout,$nth); $current = $current->getNext(); } $this->first = $current; } } $start = microtime(true); $ITER = 100; for($i = 0 ; $i < $ITER ; $i++) { $chain = new Chain(40); $chain->kill(3); } $end = microtime(true); printf("Time per iteration = %3.2f microsecondsnr",(($end - $start) * 100 / $ITER));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 7
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 7
Branch analysis from position: 17
Branch analysis from position: 7
filename:       /in/dL0cK
function name:  (null)
number of ops:  29
compiled vars:  !0 = $start, !1 = $ITER, !2 = $i, !3 = $chain, !4 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $5      
          3        ASSIGN                                                   !0, $5
   78     4        ASSIGN                                                   !1, 100
   79     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->15
   81     7    >   NEW                                              $9      'Chain'
          8        SEND_VAL_EX                                              40
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !3, $9
   82    11        INIT_METHOD_CALL                                         !3, 'kill'
         12        SEND_VAL_EX                                              3
         13        DO_FCALL                                      0          
   79    14        PRE_INC                                                  !2
         15    >   IS_SMALLER                                               !2, !1
         16      > JMPNZ                                                    ~14, ->7
   84    17    >   INIT_FCALL                                               'microtime'
         18        SEND_VAL                                                 <true>
         19        DO_ICALL                                         $15     
         20        ASSIGN                                                   !4, $15
   85    21        INIT_FCALL                                               'printf'
         22        SEND_VAL                                                 'Time+per+iteration+%3D+%253.2f+microsecondsnr'
         23        SUB                                              ~17     !4, !0
         24        MUL                                              ~18     ~17, 100
         25        DIV                                              ~19     ~18, !1
         26        SEND_VAL                                                 ~19
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Class Person:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dL0cK
function name:  __construct
number of ops:  4
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        ASSIGN_OBJ                                               'count'
          2        OP_DATA                                                  !0
    7     3      > RETURN                                                   null

End of function __construct

Function getprev:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dL0cK
function name:  getPrev
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_OBJ_R                                      ~0      'prev'
          1      > RETURN                                                   ~0
   13     2*     > RETURN                                                   null

End of function getprev

Function setprev:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dL0cK
function name:  setPrev
number of ops:  4
compiled vars:  !0 = $pr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        ASSIGN_OBJ                                               'prev'
          2        OP_DATA                                                  !0
   18     3      > RETURN                                                   null

End of function setprev

Function getnext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dL0cK
function name:  getNext
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_OBJ_R                                      ~0      'next'
          1      > RETURN                                                   ~0
   23     2*     > RETURN                                                   null

End of function getnext

Function setnext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dL0cK
function name:  setNext
number of ops:  4
compiled vars:  !0 = $nxt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   27     1        ASSIGN_OBJ                                               'next'
          2        OP_DATA                                                  !0
   28     3      > RETURN                                                   null

End of function setnext

Function shout:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dL0cK
function name:  shout
number of ops:  22
compiled vars:  !0 = $shout, !1 = $nth
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        IS_SMALLER                                               !0, !1
          3      > JMPZ                                                     ~2, ->6
   34     4    >   ADD                                              ~3      !0, 1
          5      > RETURN                                                   ~3
   36     6    >   INIT_METHOD_CALL                                         'getPrev'
          7        DO_FCALL                                      0  $4      
          8        INIT_METHOD_CALL                                         $4, 'setNext'
          9        INIT_METHOD_CALL                                         'getNext'
         10        DO_FCALL                                      0  $5      
         11        SEND_VAR_NO_REF_EX                                       $5
         12        DO_FCALL                                      0          
   37    13        INIT_METHOD_CALL                                         'getNext'
         14        DO_FCALL                                      0  $7      
         15        INIT_METHOD_CALL                                         $7, 'setPrev'
         16        INIT_METHOD_CALL                                         'getPrev'
         17        DO_FCALL                                      0  $8      
         18        SEND_VAR_NO_REF_EX                                       $8
         19        DO_FCALL                                      0          
   38    20      > RETURN                                                   1
   39    21*     > RETURN                                                   null

End of function shout

End of class Person.

Class Chain:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 4
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 4
Branch analysis from position: 25
Branch analysis from position: 4
Branch analysis from position: 21
Branch analysis from position: 13
filename:       /in/dL0cK
function name:  __construct
number of ops:  35
compiled vars:  !0 = $size, !1 = $last, !2 = $i, !3 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
   48     1        ASSIGN                                                   !1, null
   49     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->23
   51     4    >   NEW                                              $6      'Person'
          5        SEND_VAR_EX                                              !2
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !3, $6
   52     8        FETCH_OBJ_R                                      ~9      'first'
          9        IS_EQUAL                                                 ~9, null
         10      > JMPZ                                                     ~10, ->13
         11    >   ASSIGN_OBJ                                               'first'
         12        OP_DATA                                                  !3
   53    13    >   IS_NOT_EQUAL                                             !1, null
         14      > JMPZ                                                     ~12, ->21
   55    15    >   INIT_METHOD_CALL                                         !1, 'setNext'
         16        SEND_VAR_EX                                              !3
         17        DO_FCALL                                      0          
   56    18        INIT_METHOD_CALL                                         !3, 'setPrev'
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0          
   58    21    >   ASSIGN                                                   !1, !3
   49    22        PRE_INC                                                  !2
         23    >   IS_SMALLER                                               !2, !0
         24      > JMPNZ                                                    ~17, ->4
   60    25    >   FETCH_OBJ_R                                      ~18     'first'
         26        INIT_METHOD_CALL                                         ~18, 'setPrev'
         27        SEND_VAR_EX                                              !1
         28        DO_FCALL                                      0          
   61    29        INIT_METHOD_CALL                                         !1, 'setNext'
         30        CHECK_FUNC_ARG                                           
         31        FETCH_OBJ_FUNC_ARG                               $20     'first'
         32        SEND_FUNC_ARG                                            $20
         33        DO_FCALL                                      0          
   62    34      > RETURN                                                   null

End of function __construct

Function kill:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 5
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 5
Branch analysis from position: 17
Branch analysis from position: 5
filename:       /in/dL0cK
function name:  kill
number of ops:  20
compiled vars:  !0 = $nth, !1 = $current, !2 = $shout
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
   66     1        FETCH_OBJ_R                                      ~3      'first'
          2        ASSIGN                                                   !1, ~3
   67     3        ASSIGN                                                   !2, 1
   68     4      > JMP                                                      ->13
   70     5    >   INIT_METHOD_CALL                                         !1, 'shout'
          6        SEND_VAR_EX                                              !2
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !2, $6
   71    10        INIT_METHOD_CALL                                         !1, 'getNext'
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !1, $8
   68    13    >   INIT_METHOD_CALL                                         !1, 'getNext'
         14        DO_FCALL                                      0  $10     
         15        IS_NOT_IDENTICAL                                         !1, $10
         16      > JMPNZ                                                    ~11, ->5
   73    17    >   ASSIGN_OBJ                                               'first'
         18        OP_DATA                                                  !1
   74    19      > RETURN                                                   null

End of function kill

End of class Chain.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.05 ms | 1408 KiB | 17 Q