3v4l.org

run code in 300+ PHP versions simultaneously
<?php function Price($c,$pid){ //return '0.00'; $p=array(); $mintcard=array(); if(count($c)===0) return false; foreach($c as $comp => $competitor){ $p[] = $competitor['price']; if($comp=='mtgmintcard'){ $mintcard['stock'] = (int)$competitor['stock']; $mintcard['price'] = (float)$competitor['price']; } } if(count($mintcard)===0) return false; $min = _MIN($p); $avg = _AVG($p); if($mintcard['stock']===-1){ $foil=1; $pid = 40230; if($pid!==false){ $mintcard['stock'] = 24; }else{ $mintcard['stock'] = 0; } }else{ $foil=0; } if($mintcard['stock']>=1){ switch(true){ case $min <= 0.10: $price = (30 > 35 ? 0.05 : $min); break; case $min > 0.10 && $min < 0.16: $price = bcmul($min,1,2); break; case $min >= 0.16 && $min <= 0.99: $price = bcmul($avg,0.95,2); break; case $min >= 1.00 && $min <= 1.99: $price = bcdiv(bcmul((bcadd($avg,$mintcard['price'],2)),0.95,2),2,2) ; break; // + mtg price case $min >= 2.00: $price = bcmul($min,0.99,2); break; default: $price = 0; break; } }elseif($mintcard['stock']===0){ //switch(true){ /*case $min <= 0.10: $price = (_SQL_FETCHSTOCK($pid) > 35 ? 0.05 : $min); break; case $min >= 0.10 && $min < 0.16: $price = bcmul($min,0.99,2); break; case $min >= 0.16 && $min <= 0.99: $price = bcmul($avg,0.95,2); break; case $min >= 1.00 : $price = bcdiv(bcmul((bcadd($avg,$mintcard['price'],2)),0.95,2),2,2); break; // + mtg price default: $price = false; break;*/ //} $price = $avg; } if($foil===1){ $foilPrice = FoilPrice($price); echo ('pricing '.$pid.' Foil identified: increased price from '.(float)$price.' to '.$foilPrice); $price = $foilPrice; } return (float)$price; } function FoilPrice($price){ switch(true){ case $price <= 1.00: $fprice = bcmul($price,3,2); break; case $price > 1.00 && $price <= 10.00: $fprice = bcmul($price,2.5,2); break; case $price > 10.00: $fprice = bcmul($price,2,2); break; } return (float)$fprice; } function _AVG($args){ /*$count = func_num_args(); $args = func_get_args();*/ $count = count($args); $sum = array_sum($args); return (float)bcdiv($sum,$count,2); } function _MIN($args){ return (float)min($args); } $arr = array( "mtgmintcard"=> array( "date_id"=>(int)67, "price"=>(float)0.2, "stock"=>(int)-1 ), "manaleak"=> array( "date_id"=>(int)67, "price"=>(float)0.35, "stock"=>(int)-1 ), "magicmadhouse"=> array( "date_id"=>(int)67, "price"=>(float)0.49, "stock"=>(int)-1 ), ); echo Price($arr,57521);

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.0090.00618.55
8.3.50.0080.01221.27
8.3.40.0040.01119.09
8.3.30.0100.00320.27
8.3.20.0080.00018.73
8.3.10.0040.00420.84
8.3.00.0080.00023.52
8.2.180.0070.00716.63
8.2.170.0130.00622.96
8.2.160.0100.00720.43
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0000.00819.82
8.2.110.0030.00622.08
8.2.100.0110.00017.97
8.2.90.0040.00419.19
8.2.80.0030.00619.39
8.2.70.0040.00417.63
8.2.60.0080.00017.93
8.2.50.0040.00418.07
8.2.40.0040.00418.34
8.2.30.0080.00021.33
8.2.20.0080.00017.91
8.2.10.0030.00517.78
8.2.00.0040.00417.84
8.1.280.0100.00725.92
8.1.270.0040.00423.99
8.1.260.0030.00526.35
8.1.250.0000.00728.09
8.1.240.0090.00022.54
8.1.230.0040.00820.91
8.1.220.0030.00518.77
8.1.210.0000.00818.97
8.1.200.0060.00317.47
8.1.190.0030.00617.64
8.1.180.0050.00318.10
8.1.170.0040.00418.73
8.1.160.0040.00418.95
8.1.150.0080.00018.70
8.1.140.0030.00517.57
8.1.130.0040.00417.82
8.1.120.0000.00717.41
8.1.110.0000.00817.50
8.1.100.0070.00017.50
8.1.90.0000.00717.50
8.1.80.0000.00717.43
8.1.70.0040.00417.52
8.1.60.0000.00817.46
8.1.50.0040.00417.60
8.1.40.0000.00817.45
8.1.30.0000.00817.65
8.1.20.0000.00817.74
8.1.10.0050.00317.56
8.1.00.0030.00617.53
8.0.300.0000.00720.21
8.0.290.0050.00317.28
8.0.280.0040.00418.41
8.0.270.0000.00717.23
8.0.260.0030.00316.82
8.0.250.0000.00816.95
8.0.240.0060.00316.96
8.0.230.0070.00017.11
8.0.220.0000.00716.93
8.0.210.0000.00717.02
8.0.200.0000.00616.93
8.0.190.0040.00416.94
8.0.180.0060.00316.95
8.0.170.0060.00316.89
8.0.160.0000.00716.96
8.0.150.0070.00016.94
8.0.140.0000.01016.97
8.0.130.0000.00613.43
8.0.120.0040.00416.88
8.0.110.0030.00517.11
8.0.100.0070.00016.91
8.0.90.0000.00716.98
8.0.80.0030.01417.00
8.0.70.0030.00516.90
8.0.60.0040.00416.98
8.0.50.0030.00516.86
8.0.30.0150.00717.12
8.0.20.0130.00717.40
8.0.10.0000.00717.16
8.0.00.0110.01416.93
7.4.330.0000.00516.66
7.4.320.0000.00716.67
7.4.300.0030.00316.50
7.4.290.0040.00416.45
7.4.280.0050.00216.70
7.4.270.0030.00316.58
7.4.260.0060.00013.35
7.4.250.0000.00716.54
7.4.240.0000.00716.66
7.4.230.0000.00816.40
7.4.220.0040.02116.59
7.4.210.0070.01116.68
7.4.200.0040.00316.56
7.4.190.0050.00316.82
7.4.160.0110.00916.49
7.4.150.0090.00917.40
7.4.140.0110.00617.86
7.4.130.0100.00716.59
7.4.120.0120.00716.66
7.4.110.0170.00716.58
7.4.100.0070.01016.62
7.4.90.0090.01516.38
7.4.80.0110.00619.39
7.4.70.0110.00716.57
7.4.60.0040.01316.57
7.4.50.0000.00416.49
7.4.40.0100.00322.77
7.4.30.0060.00916.67
7.4.00.0090.00614.89
7.3.330.0000.00513.29
7.3.320.0030.00313.34
7.3.310.0030.00516.38
7.3.300.0050.00316.49
7.3.290.0070.01116.47
7.3.280.0080.00916.47
7.3.270.0110.00617.40
7.3.260.0090.01118.24
7.3.250.0120.00616.66
7.3.240.0000.01616.41
7.3.230.0040.01516.46
7.3.210.0150.00916.39
7.3.200.0090.01519.39
7.3.190.0070.01016.48
7.3.180.0070.01016.53
7.3.170.0110.01116.53
7.3.160.0110.01116.33
7.3.120.0090.00615.07
7.2.330.0060.01216.82
7.2.320.0150.00316.83
7.2.310.0090.01316.70
7.2.300.0060.01016.50
7.2.290.0040.01316.82
7.2.00.0000.01519.42
7.1.100.0060.01018.34
7.1.70.0040.00416.89
7.1.60.0030.02019.17
7.1.50.0040.02116.70
7.1.00.0030.03322.45
7.0.200.0000.00716.84
7.0.140.0030.07722.09
7.0.100.0100.08719.89
7.0.90.0330.08320.03
7.0.80.0000.08319.94
7.0.70.0130.03719.93
7.0.60.0300.08019.98
7.0.50.0100.07020.34
7.0.40.0070.06320.01
7.0.30.0030.05720.18
7.0.20.0000.07020.05
7.0.10.0070.06719.95
7.0.00.0030.09019.99
5.6.280.0000.07720.98
5.6.250.0130.07720.72
5.6.240.0130.07720.57
5.6.230.0100.06020.59
5.6.220.0030.09020.63
5.6.210.0070.04320.40
5.6.200.0070.08320.96
5.6.190.0070.07021.05
5.6.180.0030.05020.98
5.6.170.0070.04321.05
5.6.160.0100.08321.09
5.6.150.0070.05021.13
5.6.140.0070.08021.04
5.6.130.0030.05321.09
5.6.120.0000.06021.04
5.6.110.0130.06021.04
5.6.100.0130.07021.02
5.6.90.0070.08321.15
5.6.80.0030.04320.51
5.6.70.0070.08020.42
5.6.60.0070.07720.49
5.6.50.0070.05720.55
5.6.40.0100.04020.44
5.6.30.0100.07320.44
5.6.20.0170.07720.44
5.6.10.0100.04320.44
5.6.00.0170.07020.32
5.5.380.0030.08720.42
5.5.370.0070.04320.32
5.5.360.0070.07020.41
5.5.350.0200.07020.43
5.5.340.0070.06720.94
5.5.330.0230.07020.79
5.5.320.0100.06320.89
5.5.310.0170.07320.95
5.5.300.0170.07720.80
5.5.290.0070.04720.93
5.5.280.0100.08020.67
5.5.270.0070.09020.89
5.5.260.0100.07020.91
5.5.250.0030.08720.64
5.5.240.0130.07320.16
5.5.230.0130.03720.30
5.5.220.0100.06020.20
5.5.210.0070.08320.18
5.5.200.0130.06720.28
5.5.190.0100.07320.23
5.5.180.0200.06320.23
5.5.160.0170.06720.15
5.5.150.0100.07720.10
5.5.140.0070.07720.11
5.5.130.0100.08320.29
5.5.120.0130.06320.17
5.5.110.0100.04320.18
5.5.100.0000.08720.00
5.5.90.0170.06720.09
5.5.80.0070.08019.95
5.5.70.0100.07320.18
5.5.60.0100.04020.08
5.5.50.0130.07020.08
5.5.40.0100.07320.06
5.5.30.0130.07720.02
5.5.20.0070.05720.04
5.5.10.0070.07320.05
5.5.00.0100.06319.98
5.4.450.0100.08019.36
5.4.440.0030.08719.48
5.4.430.0100.07719.56
5.4.420.0030.05319.46
5.4.410.0130.07719.22
5.4.400.0070.05319.24
5.4.390.0100.06719.05
5.4.380.0100.07319.03
5.4.370.0100.06719.13
5.4.360.0070.08318.91
5.4.350.0030.06018.88
5.4.340.0170.05719.13
5.4.320.0000.07018.95
5.4.310.0100.04019.11
5.4.300.0070.07719.12
5.4.290.0030.06719.16
5.4.280.0030.06318.84
5.4.270.0030.07319.04
5.4.260.0130.07019.04
5.4.250.0130.06719.17
5.4.240.0100.07318.90
5.4.230.0030.07319.20
5.4.220.0070.08018.89
5.4.210.0130.06719.20
5.4.200.0100.05018.87
5.4.190.0030.04719.03
5.4.180.0070.07719.24
5.4.170.0000.07318.86
5.4.160.0100.04319.02
5.4.150.0100.05018.93
5.4.140.0170.06716.44
5.4.130.0100.07716.44
5.4.120.0000.04016.32
5.4.110.0100.07316.53
5.4.100.0100.07016.44
5.4.90.0070.06016.55
5.4.80.0070.07316.37
5.4.70.0130.03316.55
5.4.60.0100.06716.35
5.4.50.0130.05316.37
5.4.40.0100.06316.41
5.4.30.0030.07316.34
5.4.20.0030.04316.48
5.4.10.0070.03716.48
5.4.00.0000.04315.75
5.3.290.0030.07314.82
5.3.280.0100.07714.64
5.3.270.0070.07314.75
5.3.260.0100.07014.73
5.3.250.0070.06714.64
5.3.240.0030.07714.56
5.3.230.0070.06714.69
5.3.220.0030.05014.56
5.3.210.0230.06014.69
5.3.200.0070.06314.69
5.3.190.0000.07014.60
5.3.180.0030.07014.66
5.3.170.0070.05314.71
5.3.160.0070.04014.65
5.3.150.0170.06014.66
5.3.140.0030.08314.68
5.3.130.0170.06014.50
5.3.120.0070.04714.64
5.3.110.0170.03314.57
5.3.100.0070.03314.13
5.3.90.0070.03714.10
5.3.80.0100.03014.12
5.3.70.0100.04014.18
5.3.60.0100.03014.04
5.3.50.0030.03714.08
5.3.40.0070.03713.99
5.3.30.0100.03313.97
5.3.20.0000.04013.82
5.3.10.0000.03713.70
5.3.00.0030.03313.81
5.2.170.0000.03311.18
5.2.160.0130.02011.23
5.2.150.0030.03311.07
5.2.140.0000.03311.23
5.2.130.0030.02711.23
5.2.120.0030.02711.23
5.2.110.0000.03011.05
5.2.100.0000.03011.24
5.2.90.0030.03011.06
5.2.80.0000.03011.18
5.2.70.0030.03011.18
5.2.60.0030.05011.07
5.2.50.0000.06011.11
5.2.40.0030.03011.02
5.2.30.0070.02711.09
5.2.20.0030.02710.92
5.2.10.0030.02710.84
5.2.00.0000.03310.78
5.1.60.0000.03310.13
5.1.50.0000.02710.15
5.1.40.0000.04010.08
5.1.30.0030.02710.39
5.1.20.0000.02710.45
5.1.10.0070.02010.09
5.1.00.0100.0179.95
5.0.50.0000.0208.66
5.0.40.0030.0178.45
5.0.30.0000.0308.25
5.0.20.0030.0178.25
5.0.10.0000.0208.29
5.0.00.0000.0308.27
4.4.90.0000.0238.25
4.4.80.0000.0138.25
4.4.70.0000.0138.25
4.4.60.0000.0178.25
4.4.50.0030.0208.25
4.4.40.0000.0538.25
4.4.30.0000.0138.25
4.4.20.0030.0138.25
4.4.10.0000.0178.25
4.4.00.0100.0278.25
4.3.110.0000.0138.25
4.3.100.0000.0278.25
4.3.90.0000.0178.25
4.3.80.0000.0278.25
4.3.70.0000.0178.25
4.3.60.0000.0208.25
4.3.50.0000.0178.25
4.3.40.0000.0208.25
4.3.30.0000.0178.25
4.3.20.0000.0138.25
4.3.10.0000.0138.25
4.3.00.0000.0138.25

preferences:
41.81 ms | 400 KiB | 5 Q