3v4l.org

run code in 300+ PHP versions simultaneously
<?php const RATE = 100; const ITERATIONS = 10_00_000; const EXPECTED = ITERATIONS / RATE; $actual_A = 0; mt_srand(64895); $i = ITERATIONS; while ($i--) { if (mt_rand(0, RATE - 1) == 0) { $actual_A++; } } $actual_B = 0; mt_srand(64895); $i = ITERATIONS; while ($i--) { if (mt_rand(1, RATE) == 1) { $actual_B++; } } echo "Actual A: $actual_A\n"; echo "Actual B: $actual_B\n"; echo "Expected: " . EXPECTED . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 10
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 28
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 36
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 28
Branch analysis from position: 38
Branch analysis from position: 28
Branch analysis from position: 36
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 10
Branch analysis from position: 21
Branch analysis from position: 10
Branch analysis from position: 19
filename:       /in/XW30U
function name:  (null)
number of ops:  51
compiled vars:  !0 = $actual_A, !1 = $i, !2 = $actual_B
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'RATE', 100
    4     1        DECLARE_CONST                                            'ITERATIONS', 1000000
    5     2        DECLARE_CONST                                            'EXPECTED', <const ast>
    7     3        ASSIGN                                                   !0, 0
    8     4        INIT_FCALL                                               'mt_srand'
          5        SEND_VAL                                                 64895
          6        DO_ICALL                                                 
    9     7        FETCH_CONSTANT                                   ~5      'ITERATIONS'
          8        ASSIGN                                                   !1, ~5
   10     9      > JMP                                                      ->19
   11    10    >   INIT_FCALL                                               'mt_rand'
         11        SEND_VAL                                                 0
         12        FETCH_CONSTANT                                   ~7      'RATE'
         13        SUB                                              ~8      ~7, 1
         14        SEND_VAL                                                 ~8
         15        DO_ICALL                                         $9      
         16        IS_EQUAL                                                 $9, 0
         17      > JMPZ                                                     ~10, ->19
   12    18    >   PRE_INC                                                  !0
   10    19    >   POST_DEC                                         ~12     !1
         20      > JMPNZ                                                    ~12, ->10
   16    21    >   ASSIGN                                                   !2, 0
   17    22        INIT_FCALL                                               'mt_srand'
         23        SEND_VAL                                                 64895
         24        DO_ICALL                                                 
   18    25        FETCH_CONSTANT                                   ~15     'ITERATIONS'
         26        ASSIGN                                                   !1, ~15
   19    27      > JMP                                                      ->36
   20    28    >   INIT_FCALL                                               'mt_rand'
         29        SEND_VAL                                                 1
         30        FETCH_CONSTANT                                   ~17     'RATE'
         31        SEND_VAL                                                 ~17
         32        DO_ICALL                                         $18     
         33        IS_EQUAL                                                 $18, 1
         34      > JMPZ                                                     ~19, ->36
   21    35    >   PRE_INC                                                  !2
   19    36    >   POST_DEC                                         ~21     !1
         37      > JMPNZ                                                    ~21, ->28
   25    38    >   ROPE_INIT                                     3  ~23     'Actual+A%3A+'
         39        ROPE_ADD                                      1  ~23     ~23, !0
         40        ROPE_END                                      2  ~22     ~23, '%0A'
         41        ECHO                                                     ~22
   26    42        ROPE_INIT                                     3  ~26     'Actual+B%3A+'
         43        ROPE_ADD                                      1  ~26     ~26, !2
         44        ROPE_END                                      2  ~25     ~26, '%0A'
         45        ECHO                                                     ~25
   27    46        FETCH_CONSTANT                                   ~28     'EXPECTED'
         47        CONCAT                                           ~29     'Expected%3A+', ~28
         48        CONCAT                                           ~30     ~29, '%0A'
         49        ECHO                                                     ~30
         50      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.27 ms | 1011 KiB | 15 Q