3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "123 -> x 456 -> y x AND y -> d x OR y -> e x LSHIFT 2 -> f y RSHIFT 2 -> g NOT x -> h NOT y -> i"; $inputs = explode("\n", $input); function operation($s){ $matchesand = null; $and = preg_match("/(.{1,2})\sAND\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesand); if(count($matchesand)>0){ return array(1,$matchesand[1] , $matchesand[2], $matchesand[3]); } $matchesor= null; $or = preg_match("/(.{1,2})\sOR\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesor); if(count($matchesor)>0){ return array(2,$matchesor[1] , $matchesor[2], $matchesor[3]); } $matchesnot = null; $not = preg_match("/NOT\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesnot); if(count($matchesnot)>0){ return array(3,$matchesnot[1], $matchesnot[2]); } $matchesleft = null; $left = preg_match("/(.{1,2})\sLSHIFT\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesleft); if(count($matchesleft)>0){ return array(4,$matchesleft[1] , $matchesleft[2], $matchesleft[3]); } $matchesright = null; $right = preg_match("/(.{1,2})\sRSHIFT\s(.{1,2})\s->\s(.{1,2})/",$s,$matchesright); if(count($matchesright)>0){ return array(5,$matchesright[1] , $matchesright[2], $matchesright[3]); } $matches = null; $simple = preg_match("/(.{1,5})\s->\s(.{1,2})/",$s,$matches); if(count($matches)>0){ return array(6,$matches[1], $matches[2]); } } $array=array(); for($i = 'a'; $i<'z'; $i++){ $array[$i]=0; } for($i = 'a'; $i<'z'; $i++){ for($j = 'a'; $j<'z'; $j++){ $array[$i.$j]=0; } } for($i = 0; $i<count($inputs); $i++){ $values = operation($inputs[$i]); //var_dump($values); if($values[0] === 1){ if(intval($values[1])>0) $array[$values[3]] = (int)$values[1] & $array[$values[2]]; else $array[$values[3]] = $array[$values[1]] & $array[$values[2]]; } if($values[0] === 2){ $array[$values[3]] = $array[$values[1]] | $array[$values[2]]; } if($values[0] === 3){ $array[$values[2]] = ~$array[$values[1]]; } if($values[0] === 4){ $array[$values[3]] = $array[$values[1]]<<intval($values[2]); } if($values[0] === 5){ $array[$values[3]] = $array[$values[1]]>>intval($values[2]); } if($values[0] === 6){ $array[$values[2]] = intval($values[1]); } //$array[$var] = $val; } var_dump($array); ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0230.00716.88
8.3.50.0200.00522.19
8.3.40.0140.00718.93
8.3.30.0170.00719.27
8.3.20.0070.00320.41
8.3.10.0070.01323.48
8.3.00.0110.00019.79
8.2.180.0130.01716.75
8.2.170.0070.02122.96
8.2.160.0160.00319.44
8.2.150.0120.00024.18
8.2.140.0030.00724.66
8.2.130.0060.00619.39
8.2.120.0080.00326.35
8.2.110.0110.00322.34
8.2.100.0150.00018.09
8.2.90.0030.00619.30
8.2.80.0070.00418.00
8.2.70.0070.00417.86
8.2.60.0040.00818.18
8.2.50.0030.00618.07
8.2.40.0070.00320.77
8.2.30.0050.00520.70
8.2.20.0070.00318.07
8.2.10.0050.00518.35
8.2.00.0030.00618.27
8.1.280.0190.01225.92
8.1.270.0200.00720.41
8.1.260.0070.00428.09
8.1.250.0000.01028.09
8.1.240.0040.00823.84
8.1.230.0100.00617.64
8.1.220.0030.00617.78
8.1.210.0030.00618.77
8.1.200.0040.00717.60
8.1.190.0000.01017.60
8.1.180.0050.00518.10
8.1.170.0070.00318.96
8.1.160.0090.00020.85
8.1.150.0060.00319.14
8.1.140.0070.00319.79
8.1.130.0080.00417.86
8.1.120.0060.00317.84
8.1.110.0060.00617.64
8.1.100.0070.00317.78
8.1.90.0000.00817.70
8.1.80.0090.00017.80
8.1.70.0050.00517.66
8.1.60.0030.01017.82
8.1.50.0080.00317.84
8.1.40.0000.01017.80
8.1.30.0000.00917.94
8.1.20.0030.00717.96
8.1.10.0070.00317.83
8.1.00.0090.00017.78
8.0.300.0100.00018.77
8.0.290.0060.00317.00
8.0.280.0030.00618.60
8.0.270.0030.00617.40
8.0.260.0030.00517.38
8.0.250.0060.00317.28
8.0.240.0030.00617.13
8.0.230.0030.00617.11
8.0.220.0030.00717.08
8.0.210.0060.00317.05
8.0.200.0030.00617.23
8.0.190.0030.00617.19
8.0.180.0070.00417.09
8.0.170.0110.00417.09
8.0.160.0060.00317.06
8.0.150.0030.00617.22
8.0.140.0060.00317.13
8.0.130.0040.00713.53
8.0.120.0000.01017.15
8.0.110.0000.00917.22
8.0.100.0030.00617.00
8.0.90.0030.00617.01
8.0.80.0100.01917.19
8.0.70.0060.00317.21
8.0.60.0030.00616.97
8.0.50.0030.00617.05
8.0.30.0130.01717.49
8.0.20.0160.01617.41
8.0.10.0030.00717.18
8.0.00.0200.00817.15
7.4.330.0000.00616.72
7.4.320.0090.00016.75
7.4.300.0100.00016.86
7.4.290.0090.00016.93
7.4.280.0090.00016.94
7.4.270.0060.00316.84
7.4.260.0090.00016.85
7.4.250.0070.00316.77
7.4.240.0030.00616.90
7.4.230.0060.00317.02
7.4.220.0060.01816.88
7.4.210.0140.00916.96
7.4.200.0030.00616.92
7.4.160.0180.01116.67
7.4.150.0150.01517.40
7.4.140.0200.01217.86
7.4.130.0220.01516.74
7.4.120.0200.01116.73
7.4.110.0170.02116.82
7.4.100.0110.02616.79
7.4.90.0230.02316.66
7.4.80.0200.00919.39
7.4.70.0140.01416.73
7.4.60.0040.02216.75
7.4.50.0130.00717.00
7.4.40.0190.01916.85
7.4.30.0190.00916.86
7.4.00.0110.01115.20
7.3.330.0030.00713.63
7.3.320.0080.00013.70
7.3.310.0000.00916.49
7.3.300.0090.00016.68
7.3.290.0040.00416.50
7.3.280.0130.01216.61
7.3.270.0140.01517.40
7.3.260.0180.01116.57
7.3.250.0230.00816.73
7.3.240.0160.01216.77
7.3.230.0120.01816.68
7.3.210.0200.01016.93
7.3.200.0190.00817.05
7.3.190.0150.01616.65
7.3.180.0160.01216.51
7.3.170.0160.01616.54
7.3.160.0240.01016.65
7.2.330.0200.01017.01
7.2.320.0130.01616.75
7.2.310.0150.01216.76
7.2.300.0170.01016.78
7.2.290.0100.01616.98
7.2.80.0180.00416.74
7.2.60.0090.00616.77
7.2.00.0080.00819.79
7.1.200.0070.00716.14
7.1.100.0000.01317.87
7.1.70.0000.01317.43
7.1.60.0160.01319.52
7.1.50.0300.01534.95
7.1.00.0030.07722.47
7.0.200.0040.00816.91
7.0.60.0100.04320.13
7.0.50.0030.05318.00
7.0.40.0170.07720.21
7.0.30.0400.07020.26
7.0.20.0370.07720.29
7.0.10.0070.07020.32
7.0.00.0070.08320.18
5.6.280.0030.03321.12
5.6.210.0100.06020.50
5.6.200.0230.06318.18
5.6.190.0070.04320.58
5.6.180.0370.07020.58
5.6.170.0300.04320.62
5.6.160.0130.08020.54
5.6.150.0130.07718.20
5.6.140.0000.04318.26
5.6.130.0100.08318.13
5.6.120.0070.07721.05
5.6.110.0170.07021.15
5.6.100.0130.07721.03
5.6.90.0000.06721.12
5.6.80.0100.06720.57
5.5.350.0270.07320.48
5.5.340.0100.05318.00
5.5.330.0130.03720.13
5.5.320.0470.05020.19
5.5.310.0330.07320.51
5.5.300.0030.05018.08
5.5.290.0100.05317.98
5.5.280.0100.08320.94
5.5.270.0130.08020.88
5.5.260.0170.08320.80
5.5.250.0100.07320.74
5.5.240.0170.04020.08

preferences:
54.41 ms | 401 KiB | 5 Q