3v4l.org

run code in 300+ PHP versions simultaneously
<?php class BigDecimal { private $value; private $scale; function __construct(string $value){ if(preg_match('@^[0-9]*(?:.[0-9]*)?$@', $value) !== 1){ throw new Error("Invalid BigDecimal value $value"); } $this->value = $value; $this->scale = $this->getScaleOf($value); echo "scale of $value is " . $this->scale . "\n"; } private function getScale(BigDecimal $other){ return max($this->scale, $other->scale); } private function getScaleOf(string $value){ $pos = strrpos($value, '.'); if($pos === false){ return 0; } return strlen($value) - $pos; } function valueEquals($other){ } function add(BigDecimal $other){ return new self(bcadd($this, $other, $this->getScale($other))); } function div(BigDecimal $other){ return new self(bcdiv($this, $other, $this->getScale($other))); } function mod(BigDecimal $other){ // not sure if mod or rem return new self(bcmod($this, $other, $this->getScale($other))); } function mul(BigDecimal $other){ return new self(bcmul($this, $other, $this->getScale($other))); } function pow(BigDecimal $other){ return new self(bcpow($this, $other, $this->getScale($other))); } function sub(BigDecimal $other){ return new self(bcsub($this, $other, $this->getScale($other))); } function __toString(){ return $this->value; } } function d(string $value){ return new BigDecimal($value); } echo d('10.123')->sub(d('5.02'));

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.0120.00616.71
8.3.50.0060.01222.11
8.3.40.0090.00619.05
8.3.30.0040.01118.85
8.3.20.0040.00419.28
8.3.10.0000.00721.90
8.3.00.0080.00020.89
8.2.180.0090.01318.48
8.2.170.0070.00722.96
8.2.160.0110.00420.25
8.2.150.0040.00424.18
8.2.140.0090.00024.66
8.2.130.0100.00019.84
8.2.120.0050.00226.35
8.2.110.0030.00619.45
8.2.100.0080.00318.03
8.2.90.0060.00317.85
8.2.80.0000.00817.97
8.2.70.0030.00518.05
8.2.60.0000.00818.03
8.2.50.0040.00418.10
8.2.40.0000.00720.45
8.2.30.0030.00619.32
8.2.20.0040.00418.00
8.2.10.0030.00518.14
8.2.00.0050.00317.77
8.1.280.0100.00725.92
8.1.270.0000.00822.18
8.1.260.0060.00328.09
8.1.250.0040.00428.09
8.1.240.0070.00420.95
8.1.230.0040.00820.97
8.1.220.0080.00017.77
8.1.210.0050.00318.77
8.1.200.0090.00717.50
8.1.190.0080.00017.60
8.1.180.0060.00318.10
8.1.170.0080.00018.91
8.1.160.0030.00319.12
8.1.150.0040.00420.25
8.1.140.0000.00719.64
8.1.130.0000.00817.64
8.1.120.0070.00017.56
8.1.110.0040.00417.58
8.1.100.0030.00517.65
8.1.90.0000.00717.51
8.1.80.0000.00717.66
8.1.70.0000.00817.65
8.1.60.0030.00517.70
8.1.50.0040.00417.61
8.1.40.0030.00517.73
8.1.30.0040.00417.92
8.1.20.0050.00317.83
8.1.10.0060.00317.70
8.1.00.0050.00517.61
8.0.300.0040.00420.11
8.0.290.0000.00917.00
8.0.280.0070.00018.38
8.0.270.0030.00517.38
8.0.260.0040.00417.21
8.0.250.0040.00417.13
8.0.240.0040.00417.21
8.0.230.0000.00817.20
8.0.220.0040.00417.13
8.0.210.0000.00717.18
8.0.200.0000.00817.07
8.0.190.0060.00317.14
8.0.180.0040.00417.16
8.0.170.0000.00917.17
8.0.160.0050.00317.21
8.0.150.0040.00417.13
8.0.140.0040.00417.00
8.0.130.0030.00513.54
8.0.120.0050.00317.08
8.0.110.0040.00417.05
8.0.100.0040.00416.93
8.0.90.0050.00317.21
8.0.80.0100.01217.03
8.0.70.0000.00817.20
8.0.60.0050.00217.18
8.0.50.0040.00417.12
8.0.30.0060.01117.35
8.0.20.0090.01017.49
8.0.10.0050.00317.14
8.0.00.0080.01117.07
7.4.330.0000.00615.55
7.4.320.0040.00416.90
7.4.300.0000.00616.74
7.4.290.0070.00016.89
7.4.280.0030.00316.76
7.4.270.0030.00516.69
7.4.260.0070.00016.88
7.4.250.0000.00816.76
7.4.240.0000.00816.84
7.4.230.0070.00016.84
7.4.220.0110.01416.93
7.4.210.0090.00916.72
7.4.200.0040.00416.84
7.4.160.0100.00616.78
7.4.150.0130.00417.40
7.4.140.0080.01017.86
7.4.130.0130.00616.80
7.4.120.0110.01116.67
7.4.110.0070.01016.80
7.4.100.0140.00516.77
7.4.90.0000.01716.88
7.4.80.0060.01019.39
7.4.70.0130.00416.63
7.4.60.0140.00316.84
7.4.50.0100.00716.79
7.4.40.0110.01116.65
7.4.30.0090.01216.73
7.4.00.0120.00615.29
7.3.330.0000.00613.61
7.3.320.0060.00013.60
7.3.310.0000.00716.55
7.3.300.0030.00416.39
7.3.290.0080.00916.55
7.3.280.0110.00916.49
7.3.270.0120.01217.40
7.3.260.0120.00616.54
7.3.250.0090.01016.66
7.3.240.0110.01416.68
7.3.230.0100.01016.78
7.3.210.0140.00316.49
7.3.200.0120.00916.52
7.3.190.0140.00916.56
7.3.180.0100.01016.68
7.3.170.0080.00816.50
7.3.160.0110.01116.63
7.2.330.0100.00717.09
7.2.320.0100.00716.91
7.2.310.0090.00916.98
7.2.300.0130.01016.72
7.2.290.0070.01016.93
7.2.80.0080.00616.69
7.2.60.0030.01217.09
7.2.00.0040.00819.63
7.1.200.0090.00316.04
7.1.100.0130.00618.28
7.1.70.0040.00417.55
7.1.60.0070.00717.48
7.1.50.0070.01417.14
7.1.00.0000.08022.35
7.0.200.0150.00414.39
7.0.130.0070.06022.02
7.0.120.0070.05322.20
7.0.110.0100.05722.13
7.0.100.0030.06021.94
7.0.90.0070.06322.16
7.0.80.0100.05322.04
7.0.70.0130.05722.06
7.0.60.0070.05722.00
7.0.50.0070.05722.20
7.0.40.0100.05022.00
7.0.30.0100.05722.16
7.0.20.0070.05322.11
7.0.10.0100.05022.03
7.0.00.0000.06021.96
5.6.280.0070.05321.13
5.6.270.0070.05721.07
5.6.260.0100.05320.91
5.6.250.0100.05320.98
5.6.240.0130.05720.95
5.6.230.0100.05721.11
5.6.220.0070.05720.82
5.6.210.0070.06020.96
5.6.200.0100.05720.80
5.6.190.0070.06320.85
5.6.180.0030.06321.07
5.6.170.0130.04720.91
5.6.160.0070.06321.10
5.6.150.0130.05021.02
5.6.140.0130.05321.05
5.6.130.0100.06721.08
5.6.120.0070.05720.83
5.6.110.0100.06020.79
5.6.100.0100.07721.04
5.6.90.0070.05320.75
5.6.80.0070.07020.19
5.6.70.0070.06320.42
5.6.60.0070.06720.28
5.6.50.0100.05320.49
5.6.40.0100.05020.27
5.6.30.0070.05720.23
5.6.20.0170.05720.25
5.6.10.0070.05320.11
5.6.00.0070.05720.38

preferences:
38.66 ms | 401 KiB | 5 Q