3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculateAccuracy($txPower, $rssi){ if ($rssi == 0) { return -1.0; // if we cannot determine accuracy, return -1. } $ratio = $rssi*1.0/$txPower; if ($ratio < 1.0) { return pow($ratio,10); } else { $accuracy = (0.89976)*pow($ratio,7.7095) + 0.111; return $accuracy; } } echo(calculateAccuracy(-10, -70).PHP_EOL); echo(calculateAccuracy(-20, -70).PHP_EOL); echo(calculateAccuracy(-40, -70).PHP_EOL); echo(calculateAccuracy(-60, -70).PHP_EOL); echo(calculateAccuracy(-80, -70).PHP_EOL); echo(calculateAccuracy(-90, -70).PHP_EOL); echo(calculateAccuracy(-100, -70).PHP_EOL);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oYaiT
function name:  (null)
number of ops:  43
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'calculateaccuracy'
          1        SEND_VAL                                                 -10
          2        SEND_VAL                                                 -70
          3        DO_FCALL                                      0  $0      
          4        CONCAT                                           ~1      $0, '%0A'
          5        ECHO                                                     ~1
   19     6        INIT_FCALL                                               'calculateaccuracy'
          7        SEND_VAL                                                 -20
          8        SEND_VAL                                                 -70
          9        DO_FCALL                                      0  $2      
         10        CONCAT                                           ~3      $2, '%0A'
         11        ECHO                                                     ~3
   20    12        INIT_FCALL                                               'calculateaccuracy'
         13        SEND_VAL                                                 -40
         14        SEND_VAL                                                 -70
         15        DO_FCALL                                      0  $4      
         16        CONCAT                                           ~5      $4, '%0A'
         17        ECHO                                                     ~5
   21    18        INIT_FCALL                                               'calculateaccuracy'
         19        SEND_VAL                                                 -60
         20        SEND_VAL                                                 -70
         21        DO_FCALL                                      0  $6      
         22        CONCAT                                           ~7      $6, '%0A'
         23        ECHO                                                     ~7
   22    24        INIT_FCALL                                               'calculateaccuracy'
         25        SEND_VAL                                                 -80
         26        SEND_VAL                                                 -70
         27        DO_FCALL                                      0  $8      
         28        CONCAT                                           ~9      $8, '%0A'
         29        ECHO                                                     ~9
   23    30        INIT_FCALL                                               'calculateaccuracy'
         31        SEND_VAL                                                 -90
         32        SEND_VAL                                                 -70
         33        DO_FCALL                                      0  $10     
         34        CONCAT                                           ~11     $10, '%0A'
         35        ECHO                                                     ~11
   24    36        INIT_FCALL                                               'calculateaccuracy'
         37        SEND_VAL                                                 -100
         38        SEND_VAL                                                 -70
         39        DO_FCALL                                      0  $12     
         40        CONCAT                                           ~13     $12, '%0A'
         41        ECHO                                                     ~13
         42      > RETURN                                                   1

Function calculateaccuracy:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oYaiT
function name:  calculateAccuracy
number of ops:  25
compiled vars:  !0 = $txPower, !1 = $rssi, !2 = $ratio, !3 = $accuracy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        IS_EQUAL                                                 !1, 0
          3      > JMPZ                                                     ~4, ->5
    5     4    > > RETURN                                                   -1
    8     5    >   MUL                                              ~5      !1, 1
          6        DIV                                              ~6      ~5, !0
          7        ASSIGN                                                   !2, ~6
    9     8        IS_SMALLER                                               !2, 1
          9      > JMPZ                                                     ~8, ->16
   10    10    >   INIT_FCALL                                               'pow'
         11        SEND_VAR                                                 !2
         12        SEND_VAL                                                 10
         13        DO_ICALL                                         $9      
         14      > RETURN                                                   $9
         15*       JMP                                                      ->24
   13    16    >   INIT_FCALL                                               'pow'
         17        SEND_VAR                                                 !2
         18        SEND_VAL                                                 7.7095
         19        DO_ICALL                                         $10     
         20        MUL                                              ~11     $10, 0.89976
         21        ADD                                              ~12     ~11, 0.111
         22        ASSIGN                                                   !3, ~12
   14    23      > RETURN                                                   !3
   16    24*     > RETURN                                                   null

End of function calculateaccuracy

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.98 ms | 1403 KiB | 22 Q