3v4l.org

run code in 300+ PHP versions simultaneously
<?php # Modelo scenario define("DEFAULT_COU", "default"); define("UTILITY", "minimum_utility"); define("TRAFFIC", "traffic_percent"); define("MODEL_SCENARIO_GROUP_CPM", "cpm_sum"); define("MODEL_SCENARIO_CPM", "cpm"); define("MODEL_SCENARIO_UTILITY", "utility"); define("MODEL_SCENARIO_MEMBERS", "members"); echo 'DATA 1'; echo '<br/>'; $prints = 54700; $data = [ 1 => 26.14, 2 => 5.64, 3 => 5.14, 4 => 7.17, 5 => 8.11, 6 => 7.69, 7 => 7.16, ]; $distribucion = Test::getAdsDistributionV2($data, DEFAULT_COU); $printResult = Test::printDistribution($prints, $distribucion); echo '<br/>'; echo 'Distribución de ' . $prints . ' prints'; print("<pre>" . print_r($printResult, true) . "</pre>"); $spendResult = Test::spendDistribution($data, $printResult); echo 'Spend por anuncio'; print("<pre>" . print_r($spendResult, true) . "</pre>"); $spendTotal1 = Test::spendTotal($spendResult); echo 'SPEND TOTAL DATA 1 = ' . $spendTotal1 . '$'; echo '<br/>'; echo '<br/>'; echo 'DATA 2'; echo '<br/>'; $prints = 54700; $data = [ 1 => 26.14, 2 => 5.64, 3 => 5.14, 4 => 7.17, 5 => 8.11, 6 => 7.69, 7 => 7.16, ]; $distribucion = Test::getAdsDistributionV2($data, 'BR'); $printResult = Test::printDistribution($prints, $distribucion); echo '<br/>'; echo 'Distribución de ' . $prints . ' prints'; print("<pre>" . print_r($printResult, true) . "</pre>"); $spendResult = Test::spendDistribution($data, $printResult); echo 'Spend por anuncio'; print("<pre>" . print_r($spendResult, true) . "</pre>"); $spendTotal2 = Test::spendTotal($spendResult); echo 'SPEND TOTAL 2 = ' . $spendTotal2. '$'; echo '<br/>'; echo '<br/>'; echo 'DIFERENCIA = ' . ($spendTotal2 - $spendTotal1).'$'; echo '<br/>'; echo 'PORCENTAJE DE MEJORA= ' . (($spendTotal2*100/$spendTotal1)-100) . '%'; class Test { public static function spendTotal($spendResult) { $total = 0; foreach ($spendResult as $adId => $spend) { $total += $spend; } return $total; } public static function spendDistribution($data, $printResult) { $result = []; foreach ($printResult as $adId => $dist) { $result[$adId] = $printResult[$adId] * $data[$adId] / 1000; } return $result; } public static function printDistribution($prints, $distribution) { $total = 0; foreach ($distribution as $adId => $dist) { $total += $dist; } $result = []; foreach ($distribution as $adId => $dist) { $result[$adId] = $dist / $total * $prints; } return $result; } public static function getAdsDistributionV2(array $ads, $country) { if ($ads) { $dist = Test::getDist($country); $distGroupsCount = count($dist); arsort($ads); // obtener el CPM mayor de los anuncios a distribuir $firstCpm = reset($ads); // si el primer CPM es válido if ($firstCpm > 0) { // inicialmente tenemos una distribución con todos los anuncios a 0 $adDistribution = array_fill_keys(array_keys($ads), 0); $adsNormalization = array(); for ($i = 1; $i <= $distGroupsCount; $i++) { $dist[$i][MODEL_SCENARIO_GROUP_CPM] = 0; } // para cada anuncio vamos a situarlo en el grupo de CPM que le corresponda foreach ($ads as $adId => $cpm) { // normalizamos entre 0 y 1 la utilidad del anuncio, relativas al máximo CPM $adsNormalization[$adId] = array( MODEL_SCENARIO_CPM => $cpm, MODEL_SCENARIO_UTILITY => $cpm / $firstCpm, ); // IMPORTANTE: si algún anuncio tiene CPM = 0, su utilidad será 0 y tiene que caer obligatoriamente // en el último grupo, a menos que se haya indicado en la uración // una utilidad de 0 para el último grupo, // para cada grupo de CPM de la uración del primero al penúltimo for ($i = 1; $i < $distGroupsCount; $i++) { // si la utilidad del anuncio actual es mayor que la del grupo actual if ($adsNormalization[$adId][MODEL_SCENARIO_UTILITY] >= $dist[$i][UTILITY]) { // ubicamos el anuncio en el grupo de CPM $dist[$i][MODEL_SCENARIO_MEMBERS][$adId] = $cpm; // incrementamos el CPM total de anuncios del grupo con el CPM del anuncio actual $dist[$i][MODEL_SCENARIO_GROUP_CPM] += $cpm; } } // si la utilidad del anuncio actual es menor que la del penúltimo grupo, entonces pertenece al último grupo if ($adsNormalization[$adId][MODEL_SCENARIO_UTILITY] < $dist[$distGroupsCount - 1][UTILITY]) { // ubicamos el anuncio en el último grupo de CPM // no es necesario agregar CPMs pporque se distribuirán uniformemente independientemente del CPM que tengan $dist[$distGroupsCount][MODEL_SCENARIO_MEMBERS][$adId] = 1; } } // calculamos todas las frecuencias de anuncios por grupo, del primero al penúltimo // los anuncios que aparezcan en varios grupos, tendrán más peso pues se llevarán tráfico de cada uno de los grupos for ($i = 1; $i < $distGroupsCount; $i++) { // para cada anuncio dentro del grupo if (isset($dist[$i][MODEL_SCENARIO_MEMBERS])) { foreach ($dist[$i][MODEL_SCENARIO_MEMBERS] as $adId => $cpm) { // aumentamos la frecuencia del anuncio actual según su CPM relativo dentro del grupo actual $adDistribution[$adId] += ($dist[$i][TRAFFIC] * $cpm) / $dist[$i][MODEL_SCENARIO_GROUP_CPM]; } } } // tenemos dentro de $adDistribution todos los anuncios de todos los grupos (menos el último) con sus frecuencias relativas // si hay anuncios en el último grupo if (isset($dist[$distGroupsCount][MODEL_SCENARIO_MEMBERS])) { // todos los anuncios del último grupo tienen la misma frecuencia relativa, distribuyendo el tráfico correspondiente $distribution = $dist[$distGroupsCount][TRAFFIC] / count($dist[$distGroupsCount][MODEL_SCENARIO_MEMBERS]); // actualizamos las frecuencias relativas de los anuncios del último grupo foreach ($dist[$distGroupsCount][MODEL_SCENARIO_MEMBERS] as $adId => $cpm) { $adDistribution[$adId] = $distribution; } } // eliminamos todos los elementos que puedan quedar con frecuencia 0 $adDistribution = Test::array_diff($adDistribution, array(0)); // normalizamos la distribución de cada anuncio ganador tomando como base la menor frecuencia $divide = false; foreach ($adDistribution as $adId => $frequency) { if (intval($frequency) == 0) { $divide = true; break; } } if ($divide) { // obtenemos el valor de la menor frecuencia arsort($adDistribution); $lastProbability = end($adDistribution); foreach ($adDistribution as $adId => &$frequency) { $frequency = intval($frequency / $lastProbability); } } else { foreach ($adDistribution as $adId => &$frequency) { $frequency = intval($frequency); } } } else { // @codeCoverageIgnoreStart // todos los anuncios se distribuyen uniformemente $adDistribution = array_fill_keys(array_keys($ads), 1); // @codeCoverageIgnoreEnd } } else { // @codeCoverageIgnoreStart $adDistribution = array(); // @codeCoverageIgnoreEnd } return $adDistribution; } public static function array_diff(array $b, array $a) { $at = array(); foreach ($a as $i) { $at[(string)$i] = 1; } $d = array(); foreach ($b as $k => $i) { if (!isset($at[(string)$i])) { $d[$k] = $i; } } return $d; } public static function getDist($country) { $distributions = array( "BR" => array( 1 => array( UTILITY => 0.9, TRAFFIC => 85, ), 2 => array( UTILITY => 0.55, TRAFFIC => 10, ), 3 => array( UTILITY => 0.45, TRAFFIC => 4, ), 4 => array( UTILITY => 0, TRAFFIC => 1, ), ), DEFAULT_COU => array( 1 => array( UTILITY => 0.70, TRAFFIC => 70, ), 2 => array( UTILITY => 0.55, TRAFFIC => 20, ), 3 => array( UTILITY => 0.45, TRAFFIC => 8, ), 4 => array( UTILITY => 0, TRAFFIC => 2, ), ), ); return $distributions[$country]; } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dataO
function name:  (null)
number of ops:  135
compiled vars:  !0 = $prints, !1 = $data, !2 = $distribucion, !3 = $printResult, !4 = $spendResult, !5 = $spendTotal1, !6 = $spendTotal2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'DEFAULT_COU'
          2        SEND_VAL                                                 'default'
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'define'
          5        SEND_VAL                                                 'UTILITY'
          6        SEND_VAL                                                 'minimum_utility'
          7        DO_ICALL                                                 
    5     8        INIT_FCALL                                               'define'
          9        SEND_VAL                                                 'TRAFFIC'
         10        SEND_VAL                                                 'traffic_percent'
         11        DO_ICALL                                                 
    8    12        INIT_FCALL                                               'define'
         13        SEND_VAL                                                 'MODEL_SCENARIO_GROUP_CPM'
         14        SEND_VAL                                                 'cpm_sum'
         15        DO_ICALL                                                 
    9    16        INIT_FCALL                                               'define'
         17        SEND_VAL                                                 'MODEL_SCENARIO_CPM'
         18        SEND_VAL                                                 'cpm'
         19        DO_ICALL                                                 
   10    20        INIT_FCALL                                               'define'
         21        SEND_VAL                                                 'MODEL_SCENARIO_UTILITY'
         22        SEND_VAL                                                 'utility'
         23        DO_ICALL                                                 
   11    24        INIT_FCALL                                               'define'
         25        SEND_VAL                                                 'MODEL_SCENARIO_MEMBERS'
         26        SEND_VAL                                                 'members'
         27        DO_ICALL                                                 
   13    28        ECHO                                                     'DATA+1'
   14    29        ECHO                                                     '%3Cbr%2F%3E'
   15    30        ASSIGN                                                   !0, 54700
   16    31        ASSIGN                                                   !1, <array>
   25    32        INIT_STATIC_METHOD_CALL                                  'Test', 'getAdsDistributionV2'
         33        SEND_VAR_EX                                              !1
         34        FETCH_CONSTANT                                   ~16     'DEFAULT_COU'
         35        SEND_VAL_EX                                              ~16
         36        DO_FCALL                                      0  $17     
         37        ASSIGN                                                   !2, $17
   26    38        INIT_STATIC_METHOD_CALL                                  'Test', 'printDistribution'
         39        SEND_VAR_EX                                              !0
         40        SEND_VAR_EX                                              !2
         41        DO_FCALL                                      0  $19     
         42        ASSIGN                                                   !3, $19
   27    43        ECHO                                                     '%3Cbr%2F%3E'
   28    44        CONCAT                                           ~21     'Distribuci%C3%B3n+de+', !0
         45        CONCAT                                           ~22     ~21, '+prints'
         46        ECHO                                                     ~22
   29    47        INIT_FCALL                                               'print_r'
         48        SEND_VAR                                                 !3
         49        SEND_VAL                                                 <true>
         50        DO_ICALL                                         $23     
         51        CONCAT                                           ~24     '%3Cpre%3E', $23
         52        CONCAT                                           ~25     ~24, '%3C%2Fpre%3E'
         53        ECHO                                                     ~25
   30    54        INIT_STATIC_METHOD_CALL                                  'Test', 'spendDistribution'
         55        SEND_VAR_EX                                              !1
         56        SEND_VAR_EX                                              !3
         57        DO_FCALL                                      0  $26     
         58        ASSIGN                                                   !4, $26
   31    59        ECHO                                                     'Spend+por+anuncio'
   32    60        INIT_FCALL                                               'print_r'
         61        SEND_VAR                                                 !4
         62        SEND_VAL                                                 <true>
         63        DO_ICALL                                         $28     
         64        CONCAT                                           ~29     '%3Cpre%3E', $28
         65        CONCAT                                           ~30     ~29, '%3C%2Fpre%3E'
         66        ECHO                                                     ~30
   33    67        INIT_STATIC_METHOD_CALL                                  'Test', 'spendTotal'
         68        SEND_VAR_EX                                              !4
         69        DO_FCALL                                      0  $31     
         70        ASSIGN                                                   !5, $31
   34    71        CONCAT                                           ~33     'SPEND+TOTAL+DATA+1+%3D+', !5
         72        CONCAT                                           ~34     ~33, '%24'
         73        ECHO                                                     ~34
   36    74        ECHO                                                     '%3Cbr%2F%3E'
   37    75        ECHO                                                     '%3Cbr%2F%3E'
   38    76        ECHO                                                     'DATA+2'
   39    77        ECHO                                                     '%3Cbr%2F%3E'
   40    78        ASSIGN                                                   !0, 54700
   41    79        ASSIGN                                                   !1, <array>
   50    80        INIT_STATIC_METHOD_CALL                                  'Test', 'getAdsDistributionV2'
         81        SEND_VAR_EX                                              !1
         82        SEND_VAL_EX                                              'BR'
         83        DO_FCALL                                      0  $37     
         84        ASSIGN                                                   !2, $37
   51    85        INIT_STATIC_METHOD_CALL                                  'Test', 'printDistribution'
         86        SEND_VAR_EX                                              !0
         87        SEND_VAR_EX                                              !2
         88        DO_FCALL                                      0  $39     
         89        ASSIGN                                                   !3, $39
   52    90        ECHO                                                     '%3Cbr%2F%3E'
   53    91        CONCAT                                           ~41     'Distribuci%C3%B3n+de+', !0
         92        CONCAT                                           ~42     ~41, '+prints'
         93        ECHO                                                     ~42
   54    94        INIT_FCALL                                               'print_r'
         95        SEND_VAR                                                 !3
         96        SEND_VAL                                                 <true>
         97        DO_ICALL                                         $43     
         98        CONCAT                                           ~44     '%3Cpre%3E', $43
         99        CONCAT                                           ~45     ~44, '%3C%2Fpre%3E'
        100        ECHO                                                     ~45
   55   101        INIT_STATIC_METHOD_CALL                                  'Test', 'spendDistribution'
        102        SEND_VAR_EX                                              !1
        103        SEND_VAR_EX                                              !3
        104        DO_FCALL                                      0  $46     
        105        ASSIGN                                                   !4, $46
   56   106        ECHO                                                     'Spend+por+anuncio'
   57   107        INIT_FCALL                                               'print_r'
        108        SEND_VAR                                                 !4
        109        SEND_VAL                                                 <true>
        110        DO_ICALL                                         $48     
        111        CONCAT                                           ~49     '%3Cpre%3E', $48
        112        CONCAT                                           ~50     ~49, '%3C%2Fpre%3E'
        113        ECHO                                                     ~50
   58   114        INIT_STATIC_METHOD_CALL                                  'Test', 'spendTotal'
        115        SEND_VAR_EX                                              !4
        116        DO_FCALL                                      0  $51     
        117        ASSIGN                                                   !6, $51
   59   118        CONCAT                                           ~53     'SPEND+TOTAL+2+%3D+', !6
        119        CONCAT                                           ~54     ~53, '%24'
        120        ECHO                                                     ~54
   60   121        ECHO                                                     '%3Cbr%2F%3E'
   61   122        ECHO                                                     '%3Cbr%2F%3E'
   62   123        SUB                                              ~55     !6, !5
        124        CONCAT                                           ~56     'DIFERENCIA+%3D+', ~55
        125        CONCAT                                           ~57     ~56, '%24'
        126        ECHO                                                     ~57
   63   127        ECHO                                                     '%3Cbr%2F%3E'
   64   128        MUL                                              ~58     !6, 100
        129        DIV                                              ~59     ~58, !5
        130        SUB                                              ~60     ~59, 100
        131        CONCAT                                           ~61     'PORCENTAJE+DE+MEJORA%3D+', ~60
        132        CONCAT                                           ~62     ~61, '%25'
        133        ECHO                                                     ~62
  275   134      > RETURN                                                   1

Class Test:
Function spendtotal:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/dataO
function name:  spendTotal
number of ops:  10
compiled vars:  !0 = $spendResult, !1 = $total, !2 = $spend, !3 = $adId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   74     0  E >   RECV                                             !0      
   76     1        ASSIGN                                                   !1, 0
   77     2      > FE_RESET_R                                       $5      !0, ->7
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->7
          4    >   ASSIGN                                                   !3, ~6
   78     5        ASSIGN_OP                                     1          !1, !2
   77     6      > JMP                                                      ->3
          7    >   FE_FREE                                                  $5
   80     8      > RETURN                                                   !1
   81     9*     > RETURN                                                   null

End of function spendtotal

Function spenddistribution:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/dataO
function name:  spendDistribution
number of ops:  16
compiled vars:  !0 = $data, !1 = $printResult, !2 = $result, !3 = $dist, !4 = $adId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   83     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   85     2        ASSIGN                                                   !2, <array>
   86     3      > FE_RESET_R                                       $6      !1, ->13
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->13
          5    >   ASSIGN                                                   !4, ~7
   87     6        FETCH_DIM_R                                      ~10     !1, !4
          7        FETCH_DIM_R                                      ~11     !0, !4
          8        MUL                                              ~12     ~10, ~11
          9        DIV                                              ~13     ~12, 1000
         10        ASSIGN_DIM                                               !2, !4
         11        OP_DATA                                                  ~13
   86    12      > JMP                                                      ->4
         13    >   FE_FREE                                                  $6
   89    14      > RETURN                                                   !2
   90    15*     > RETURN                                                   null

End of function spenddistribution

Function printdistribution:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 8
filename:       /in/dataO
function name:  printDistribution
number of ops:  21
compiled vars:  !0 = $prints, !1 = $distribution, !2 = $total, !3 = $dist, !4 = $adId, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   92     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   94     2        ASSIGN                                                   !2, 0
   95     3      > FE_RESET_R                                       $7      !1, ->8
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->8
          5    >   ASSIGN                                                   !4, ~8
   96     6        ASSIGN_OP                                     1          !2, !3
   95     7      > JMP                                                      ->4
          8    >   FE_FREE                                                  $7
   99     9        ASSIGN                                                   !5, <array>
  100    10      > FE_RESET_R                                       $12     !1, ->18
         11    > > FE_FETCH_R                                       ~13     $12, !3, ->18
         12    >   ASSIGN                                                   !4, ~13
  101    13        DIV                                              ~16     !3, !2
         14        MUL                                              ~17     !0, ~16
         15        ASSIGN_DIM                                               !5, !4
         16        OP_DATA                                                  ~17
  100    17      > JMP                                                      ->11
         18    >   FE_FREE                                                  $12
  104    19      > RETURN                                                   !5
  105    20*     > RETURN                                                   null

End of function printdistribution

Function getadsdistributionv2:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 184
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 175
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 29
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 83
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 83
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 48
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 82
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 82
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 65
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 48
Branch analysis from position: 68
Branch analysis from position: 48
Branch analysis from position: 65
Branch analysis from position: 83
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
2 jumps found. (Code = 44) Position 1 = 111, Position 2 = 86
Branch analysis from position: 111
2 jumps found. (Code = 43) Position 1 = 115, Position 2 = 134
Branch analysis from position: 115
2 jumps found. (Code = 77) Position 1 = 128, Position 2 = 133
Branch analysis from position: 128
2 jumps found. (Code = 78) Position 1 = 129, Position 2 = 133
Branch analysis from position: 129
1 jumps found. (Code = 42) Position 1 = 128
Branch analysis from position: 128
Branch analysis from position: 133
2 jumps found. (Code = 77) Position 1 = 141, Position 2 = 149
Branch analysis from position: 141
2 jumps found. (Code = 78) Position 1 = 142, Position 2 = 149
Branch analysis from position: 142
2 jumps found. (Code = 43) Position 1 = 146, Position 2 = 148
Branch analysis from position: 146
1 jumps found. (Code = 42) Position 1 = 149
Branch analysis from position: 149
2 jumps found. (Code = 43) Position 1 = 151, Position 2 = 167
Branch analysis from position: 151
2 jumps found. (Code = 125) Position 1 = 159, Position 2 = 165
Branch analysis from position: 159
2 jumps found. (Code = 126) Position 1 = 160, Position 2 = 165
Branch analysis from position: 160
1 jumps found. (Code = 42) Position 1 = 159
Branch analysis from position: 159
Branch analysis from position: 165
1 jumps found. (Code = 42) Position 1 = 174
Branch analysis from position: 174
1 jumps found. (Code = 42) Position 1 = 183
Branch analysis from position: 183
1 jumps found. (Code = 42) Position 1 = 185
Branch analysis from position: 185
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 165
Branch analysis from position: 167
2 jumps found. (Code = 125) Position 1 = 168, Position 2 = 173
Branch analysis from position: 168
2 jumps found. (Code = 126) Position 1 = 169, Position 2 = 173
Branch analysis from position: 169
1 jumps found. (Code = 42) Position 1 = 168
Branch analysis from position: 168
Branch analysis from position: 173
1 jumps found. (Code = 42) Position 1 = 183
Branch analysis from position: 183
Branch analysis from position: 173
Branch analysis from position: 148
1 jumps found. (Code = 42) Position 1 = 141
Branch analysis from position: 141
Branch analysis from position: 149
Branch analysis from position: 149
Branch analysis from position: 133
Branch analysis from position: 134
Branch analysis from position: 86
2 jumps found. (Code = 43) Position 1 = 90, Position 2 = 108
Branch analysis from position: 90
2 jumps found. (Code = 77) Position 1 = 94, Position 2 = 107
Branch analysis from position: 94
2 jumps found. (Code = 78) Position 1 = 95, Position 2 = 107
Branch analysis from position: 95
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
Branch analysis from position: 107
2 jumps found. (Code = 44) Position 1 = 111, Position 2 = 86
Branch analysis from position: 111
Branch analysis from position: 86
Branch analysis from position: 107
Branch analysis from position: 108
Branch analysis from position: 83
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 29
Branch analysis from position: 36
Branch analysis from position: 29
Branch analysis from position: 175
1 jumps found. (Code = 42) Position 1 = 185
Branch analysis from position: 185
Branch analysis from position: 184
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dataO
function name:  getAdsDistributionV2
number of ops:  187
compiled vars:  !0 = $ads, !1 = $country, !2 = $dist, !3 = $distGroupsCount, !4 = $firstCpm, !5 = $adDistribution, !6 = $adsNormalization, !7 = $i, !8 = $cpm, !9 = $adId, !10 = $distribution, !11 = $divide, !12 = $frequency, !13 = $lastProbability
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  108     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  110     2      > JMPZ                                                     !0, ->184
  111     3    >   INIT_STATIC_METHOD_CALL                                  'Test', 'getDist'
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $14     
          6        ASSIGN                                                   !2, $14
  112     7        COUNT                                            ~16     !2
          8        ASSIGN                                                   !3, ~16
  113     9        INIT_FCALL                                               'arsort'
         10        SEND_REF                                                 !0
         11        DO_ICALL                                                 
  115    12        INIT_FCALL                                               'reset'
         13        SEND_REF                                                 !0
         14        DO_ICALL                                         $19     
         15        ASSIGN                                                   !4, $19
  117    16        IS_SMALLER                                               0, !4
         17      > JMPZ                                                     ~21, ->175
  119    18    >   INIT_FCALL                                               'array_fill_keys'
         19        INIT_FCALL                                               'array_keys'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $22     
         22        SEND_VAR                                                 $22
         23        SEND_VAL                                                 0
         24        DO_ICALL                                         $23     
         25        ASSIGN                                                   !5, $23
  120    26        ASSIGN                                                   !6, <array>
  121    27        ASSIGN                                                   !7, 1
         28      > JMP                                                      ->34
  122    29    >   FETCH_CONSTANT                                   ~28     'MODEL_SCENARIO_GROUP_CPM'
         30        FETCH_DIM_W                                      $27     !2, !7
         31        ASSIGN_DIM                                               $27, ~28
         32        OP_DATA                                                  0
  121    33        PRE_INC                                                  !7
         34    >   IS_SMALLER_OR_EQUAL                                      !7, !3
         35      > JMPNZ                                                    ~31, ->29
  126    36    > > FE_RESET_R                                       $32     !0, ->83
         37    > > FE_FETCH_R                                       ~33     $32, !8, ->83
         38    >   ASSIGN                                                   !9, ~33
  129    39        FETCH_CONSTANT                                   ~36     'MODEL_SCENARIO_CPM'
         40        INIT_ARRAY                                       ~37     !8, ~36
  130    41        FETCH_CONSTANT                                   ~38     'MODEL_SCENARIO_UTILITY'
         42        DIV                                              ~39     !8, !4
         43        ADD_ARRAY_ELEMENT                                ~37     ~39, ~38
  128    44        ASSIGN_DIM                                               !6, !9
  130    45        OP_DATA                                                  ~37
  137    46        ASSIGN                                                   !7, 1
         47      > JMP                                                      ->66
  139    48    >   FETCH_CONSTANT                                   ~42     'MODEL_SCENARIO_UTILITY'
         49        FETCH_DIM_R                                      ~41     !6, !9
         50        FETCH_DIM_R                                      ~43     ~41, ~42
         51        FETCH_CONSTANT                                   ~45     'UTILITY'
         52        FETCH_DIM_R                                      ~44     !2, !7
         53        FETCH_DIM_R                                      ~46     ~44, ~45
         54        IS_SMALLER_OR_EQUAL                                      ~46, ~43
         55      > JMPZ                                                     ~47, ->65
  141    56    >   FETCH_CONSTANT                                   ~49     'MODEL_SCENARIO_MEMBERS'
         57        FETCH_DIM_W                                      $48     !2, !7
         58        FETCH_DIM_W                                      $50     $48, ~49
         59        ASSIGN_DIM                                               $50, !9
         60        OP_DATA                                                  !8
  144    61        FETCH_CONSTANT                                   ~53     'MODEL_SCENARIO_GROUP_CPM'
         62        FETCH_DIM_RW                                     $52     !2, !7
         63        ASSIGN_DIM_OP                +=               1          $52, ~53
         64        OP_DATA                                                  !8
  137    65    >   PRE_INC                                                  !7
         66    >   IS_SMALLER                                               !7, !3
         67      > JMPNZ                                                    ~56, ->48
  148    68    >   FETCH_CONSTANT                                   ~58     'MODEL_SCENARIO_UTILITY'
         69        FETCH_DIM_R                                      ~57     !6, !9
         70        FETCH_DIM_R                                      ~59     ~57, ~58
         71        SUB                                              ~60     !3, 1
         72        FETCH_CONSTANT                                   ~62     'UTILITY'
         73        FETCH_DIM_R                                      ~61     !2, ~60
         74        FETCH_DIM_R                                      ~63     ~61, ~62
         75        IS_SMALLER                                               ~59, ~63
         76      > JMPZ                                                     ~64, ->82
  151    77    >   FETCH_CONSTANT                                   ~66     'MODEL_SCENARIO_MEMBERS'
         78        FETCH_DIM_W                                      $65     !2, !3
         79        FETCH_DIM_W                                      $67     $65, ~66
         80        ASSIGN_DIM                                               $67, !9
         81        OP_DATA                                                  1
  126    82    > > JMP                                                      ->37
         83    >   FE_FREE                                                  $32
  157    84        ASSIGN                                                   !7, 1
         85      > JMP                                                      ->109
  159    86    >   FETCH_CONSTANT                                   ~71     'MODEL_SCENARIO_MEMBERS'
         87        FETCH_DIM_IS                                     ~70     !2, !7
         88        ISSET_ISEMPTY_DIM_OBJ                         0          ~70, ~71
         89      > JMPZ                                                     ~72, ->108
  160    90    >   FETCH_CONSTANT                                   ~74     'MODEL_SCENARIO_MEMBERS'
         91        FETCH_DIM_R                                      ~73     !2, !7
         92        FETCH_DIM_R                                      ~75     ~73, ~74
         93      > FE_RESET_R                                       $76     ~75, ->107
         94    > > FE_FETCH_R                                       ~77     $76, !8, ->107
         95    >   ASSIGN                                                   !9, ~77
  163    96        FETCH_CONSTANT                                   ~81     'TRAFFIC'
         97        FETCH_DIM_R                                      ~80     !2, !7
         98        FETCH_DIM_R                                      ~82     ~80, ~81
         99        MUL                                              ~83     !8, ~82
  164   100        FETCH_CONSTANT                                   ~85     'MODEL_SCENARIO_GROUP_CPM'
        101        FETCH_DIM_R                                      ~84     !2, !7
        102        FETCH_DIM_R                                      ~86     ~84

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
294.17 ms | 1428 KiB | 26 Q