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 [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 [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 [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 [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 [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 [6,$matches[1], $matches[2]]; } } $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.0130.00718.54
8.3.50.0210.00922.13
8.3.40.0200.00018.96
8.3.30.0140.01019.22
8.3.20.0070.00320.48
8.3.10.0040.00723.61
8.3.00.0040.00719.98
8.2.180.0190.00618.47
8.2.170.0140.00722.96
8.2.160.0100.01020.68
8.2.150.0080.00424.18
8.2.140.0100.00024.66
8.2.130.0050.00519.24
8.2.120.0030.00726.35
8.2.110.0110.00322.23
8.2.100.0170.00018.18
8.2.90.0090.00019.43
8.2.80.0030.00618.15
8.2.70.0080.00517.88
8.2.60.0080.00417.93
8.2.50.0060.00618.07
8.2.40.0030.00722.16
8.2.30.0030.00620.90
8.2.20.0090.00017.93
8.2.10.0030.00618.28
8.2.00.0070.00318.27
8.1.280.0170.01025.92
8.1.270.0100.00020.50
8.1.260.0030.00728.09
8.1.250.0070.00328.09
8.1.240.0070.00722.46
8.1.230.0000.01419.16
8.1.220.0000.00917.78
8.1.210.0090.00018.77
8.1.200.0100.00317.72
8.1.190.0030.00617.61
8.1.180.0040.00718.10
8.1.170.0050.00518.86
8.1.160.0030.00720.97
8.1.150.0090.00019.15
8.1.140.0000.01119.71
8.1.130.0060.00317.97
8.1.120.0030.00617.73
8.1.110.0090.00317.76
8.1.100.0060.00317.81
8.1.90.0030.00617.81
8.1.80.0060.00317.68
8.1.70.0000.01017.73
8.1.60.0040.00717.93
8.1.50.0070.00417.76
8.1.40.0040.00717.75
8.1.30.0040.00717.79
8.1.20.0030.00617.86
8.1.10.0100.00017.81
8.1.00.0000.01017.70
8.0.300.0090.00018.77
8.0.290.0000.00916.88
8.0.280.0060.00318.52
8.0.270.0060.00317.33
8.0.260.0040.00417.45
8.0.250.0030.00617.21
8.0.240.0000.00817.24
8.0.230.0060.00317.25
8.0.220.0040.00417.15
8.0.210.0060.00317.08
8.0.200.0080.00017.13
8.0.190.0070.00317.14
8.0.180.0060.00317.11
8.0.170.0030.01017.23
8.0.160.0060.00317.23
8.0.150.0030.00617.07
8.0.140.0090.00017.12
8.0.130.0040.00413.64
8.0.120.0040.00717.18
8.0.110.0030.00617.17
8.0.100.0030.00617.04
8.0.90.0090.00017.12
8.0.80.0160.00617.14
8.0.70.0040.00417.21
8.0.60.0040.00417.24
8.0.50.0050.00516.97
8.0.30.0230.01217.26
8.0.20.0170.01917.50
8.0.10.0000.00917.25
8.0.00.0220.01017.10
7.4.330.0000.00816.82
7.4.320.0040.00416.88
7.4.300.0000.01216.84
7.4.290.0040.00416.95
7.4.280.0040.00416.95
7.4.270.0040.00416.95
7.4.260.0060.00316.78
7.4.250.0030.00716.81
7.4.240.0060.00316.88
7.4.230.0090.00016.99
7.4.220.0130.01016.84
7.4.210.0120.01316.95
7.4.200.0060.00316.88
7.4.160.0150.01516.93
7.4.150.0190.03017.40
7.4.140.0190.01617.86
7.4.130.0210.01316.85
7.4.120.0190.01216.99
7.4.110.0180.02216.79
7.4.100.0000.02816.82
7.4.90.0150.02216.88
7.4.80.0130.01719.39
7.4.70.0100.01416.93
7.4.60.0090.02516.65
7.4.50.0100.01016.56
7.4.40.0150.01216.74
7.4.30.0140.01116.65
7.4.00.0130.00715.33
7.3.330.0060.00013.61
7.3.320.0000.00713.48
7.3.310.0080.00016.49
7.3.300.0000.00916.68
7.3.290.0040.00416.64
7.3.280.0130.01316.64
7.3.270.0210.01217.40
7.3.260.0290.01316.88
7.3.250.0160.01816.73
7.3.240.0120.01716.82
7.3.230.0210.01716.84
7.3.210.0130.01616.88
7.3.200.0210.00616.84
7.3.190.0160.01016.57
7.3.180.0110.01516.88
7.3.170.0160.01016.79
7.3.160.0200.00816.81
7.2.330.0150.01617.02
7.2.320.0260.00316.78
7.2.310.0100.01817.01
7.2.300.0100.01717.00
7.2.290.0170.01116.75
7.2.00.0070.00719.54
7.1.100.0080.00418.60
7.1.70.0030.00617.39
7.1.60.0130.01719.52
7.1.50.0070.01316.82
7.1.00.0070.07722.48
7.0.200.0040.00916.86
7.0.120.0070.07022.02
7.0.110.0030.08022.03
7.0.100.0070.07322.16
7.0.90.0000.08321.95
7.0.80.0130.06722.07
7.0.70.0070.04322.14
7.0.60.0070.07321.73
7.0.50.0000.07722.16
7.0.40.0030.07722.07
7.0.30.0070.07322.16
7.0.20.0070.07022.20
7.0.10.0000.06722.05
7.0.00.0130.07022.06
5.6.280.0100.07021.17
5.6.260.0030.07721.09
5.6.250.0070.07321.14
5.6.240.0130.07020.79
5.6.230.0030.05320.82
5.6.220.0070.04721.12
5.6.210.0070.07321.02
5.6.200.0030.08021.04
5.6.190.0030.07721.05
5.6.180.0030.07721.06
5.6.170.0130.06320.79
5.6.160.0030.07720.84
5.6.150.0070.07720.96
5.6.140.0070.07320.86
5.6.130.0070.07321.16
5.6.120.0030.08020.82
5.6.110.0100.07021.03
5.6.100.0100.07321.06
5.6.90.0070.07721.08
5.6.80.0070.06720.25
5.6.70.0030.06020.41
5.6.60.0070.07320.46
5.6.50.0100.06720.39
5.6.40.0100.07020.15
5.6.30.0030.07720.25
5.6.20.0100.05320.29
5.6.10.0130.06720.39
5.6.00.0100.07020.38
5.5.380.0030.06017.71
5.5.370.0070.07017.58
5.5.360.0070.04717.61
5.5.350.0100.06717.55
5.5.340.0000.07318.05
5.5.330.0030.07718.14
5.5.320.0030.07318.08
5.5.310.0100.06718.22
5.5.300.0030.07317.98
5.5.290.0070.07317.98
5.5.280.0030.08017.97
5.5.270.0000.08018.21
5.5.260.0070.07317.92
5.5.250.0130.06717.76
5.5.240.0100.06317.37
5.5.230.0030.07717.23
5.5.220.0070.07017.47
5.5.210.0030.07017.23
5.5.200.0070.06717.21
5.5.190.0030.07317.40
5.5.180.0070.06717.28
5.5.160.0030.07017.46
5.5.150.0070.07017.49
5.5.140.0030.06717.45
5.5.130.0130.05317.60
5.5.120.0130.05317.29
5.5.110.0030.07017.28
5.5.100.0030.07317.18
5.5.90.0070.06717.36
5.5.80.0000.07317.47
5.5.70.0070.06317.49
5.5.60.0030.07017.32
5.5.50.0030.06017.57
5.5.40.0070.04317.46
5.5.30.0070.06317.46
5.5.20.0030.07317.31
5.5.10.0100.07017.36
5.5.00.0070.07017.17

preferences:
52.97 ms | 401 KiB | 5 Q