3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Point { public $X; public $Y; function __construct($X, $Y) { $this->X = $X; $this->Y = $Y; } } $moves = 4; $mouseX = 100; $mouseY = 200; $point = new Point(500, 400); $startAngle = rand(0, 90); echo 'Angle = '.$startAngle."\r\n"; $angles = array($startAngle); for ( $i=1; $i<$moves; $i++ ) { $angles[$i] = $angles[$i-1] + (90 - 2*$startAngle)/($moves-1); } $lineHeightDiv = 0; foreach ( $angles as $angle ) { $lineHeightDiv += sin($angle*pi()/180); } $lineHeight = ($point->Y-$mouseY)/$lineHeightDiv; echo 'LineHeight = '.$lineHeight."\r\n"; $lineWidthDiv = 0; foreach ( $angles as $angle ) { $lineWidthDiv += cos($angle*pi()/180); } $lineWidth = ($point->X-$mouseX)/$lineWidthDiv; echo 'LineWidth = '.$lineWidth."\r\n"; $points = array(new Point($mouseX, $mouseY)); for ( $i=1; $i<=$moves; $i++ ) { $x = $points[$i-1]->X + $lineWidth*cos($angles[$i-1]*pi()/180); $y = $points[$i-1]->Y + $lineHeight*sin($angles[$i-1]*pi()/180); $points[] = new Point($x, $y); } var_dump($points);

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)
7.3.10.0000.01217.01
7.3.00.0060.01017.05
7.2.130.0070.00717.07
7.2.120.0060.01017.31
7.2.110.0090.00617.14
7.2.100.0060.00617.38
7.2.90.0030.00917.34
7.2.80.0030.01416.80
7.2.70.0030.00917.17
7.2.60.0080.00616.88
7.2.50.0040.01117.13
7.2.40.0070.00716.98
7.2.30.0070.01117.39
7.2.20.0000.01317.06
7.2.10.0060.00817.25
7.2.00.0060.01118.62
7.1.250.0040.00416.20
7.1.70.0000.00817.27
7.1.60.0040.00819.46
7.1.50.0070.01017.20
7.1.00.0000.07722.76
7.0.200.0000.01017.16
7.0.140.0000.07022.21
7.0.60.0100.06720.16
7.0.50.0100.07718.25
7.0.40.0070.04720.39
7.0.30.0200.04720.23
7.0.20.0270.08320.36
7.0.10.0030.04320.28
7.0.00.0030.04720.26
5.6.280.0070.07021.05
5.6.210.0000.04720.85
5.6.200.0130.08018.34
5.6.190.0200.08020.73
5.6.180.0200.05720.52
5.6.170.0330.08720.62
5.6.160.0300.03720.73
5.6.150.0030.04018.38
5.6.140.0070.08318.42
5.6.130.0030.08318.34
5.6.120.0070.08721.38
5.6.110.0070.07721.28
5.6.100.0100.08321.27
5.6.90.0030.04321.29
5.6.80.0100.07720.67
5.6.70.0070.03020.67
5.5.350.0170.07720.56
5.5.340.0070.08018.06
5.5.330.0030.05320.46
5.5.320.0100.08720.47
5.5.310.0200.04720.49
5.5.300.0100.07018.22
5.5.290.0070.08318.14
5.5.280.0000.05721.20
5.5.270.0100.07321.10
5.5.260.0130.07720.96
5.5.250.0070.07320.77
5.5.240.0270.05320.35
5.4.450.0900.05719.60
5.4.440.0230.06019.37
5.4.430.0270.04719.39
5.4.420.0270.04719.50
5.4.410.0330.06019.70
5.4.400.0300.05019.34
5.4.390.0270.07719.21
5.4.380.0200.05718.66
5.4.370.0270.05019.11
5.4.360.0230.06018.90
5.4.350.0230.05718.87
5.4.340.0270.05718.95
5.4.320.0040.03812.55
5.4.310.0060.03912.54
5.4.300.0040.04012.55
5.4.290.0060.03812.55
5.4.280.0070.05412.42
5.4.270.0090.05612.42
5.4.260.0110.05412.42
5.4.250.0090.05812.43
5.4.240.0100.05312.42
5.4.230.0140.05512.41
5.4.220.0120.05812.41
5.4.210.0110.05812.41
5.4.200.0140.05112.41
5.4.190.0090.04912.40
5.4.180.0110.04312.41
5.4.170.0050.06112.43
5.4.160.0140.03912.42
5.4.150.0090.04812.41
5.4.140.0090.05312.10
5.4.130.0070.04312.09
5.4.120.0060.04612.04
5.4.110.0090.04212.04
5.4.100.0060.03912.05
5.4.90.0100.04812.03
5.4.80.0120.04812.03
5.4.70.0060.03912.04
5.4.60.0090.04412.06
5.4.50.0110.04712.03
5.4.40.0140.04612.02
5.4.30.0110.04412.02
5.4.20.0150.04712.03
5.4.10.0150.07412.03
5.4.00.0070.04811.52
5.3.290.0070.03912.80
5.3.280.0120.05912.71
5.3.270.0130.04912.72
5.3.260.0080.06112.73
5.3.250.0080.05812.73
5.3.240.0090.05612.73
5.3.230.0120.04712.71
5.3.220.0120.05412.68
5.3.210.0100.05712.68
5.3.200.0100.05712.68
5.3.190.0110.05412.69
5.3.180.0100.05712.68
5.3.170.0120.05612.68
5.3.160.0150.05312.69
5.3.150.0160.05112.69
5.3.140.0120.05012.68
5.3.130.0120.05312.67
5.3.120.0100.05712.67
5.3.110.0080.05712.66
5.3.100.0090.05112.15
5.3.90.0110.06012.14
5.3.80.0110.04912.13
5.3.70.0090.04012.13
5.3.60.0100.04412.11
5.3.50.0070.04512.06
5.3.40.0100.03712.06
5.3.30.0090.04612.02
5.3.20.0090.04611.79
5.3.10.0080.05911.76
5.3.00.0080.04811.75
5.2.170.0110.0409.25
5.2.160.0050.0419.25
5.2.150.0160.0389.25
5.2.140.0120.0439.24
5.2.130.0100.0429.20
5.2.120.0100.0379.21
5.2.110.0060.0409.21
5.2.100.0140.0349.22
5.2.90.0090.0449.21
5.2.80.0090.0549.23
5.2.70.0120.0449.20
5.2.60.0080.0419.16
5.2.50.0060.0439.14
5.2.40.0080.0399.11
5.2.30.0110.0359.09
5.2.20.0080.0399.07
5.2.10.0080.0359.03
5.2.00.0100.0478.86
5.1.60.0120.0368.15
5.1.50.0090.0408.14
5.1.40.0130.0368.12
5.1.30.0110.0388.47
5.1.20.0180.0378.50
5.1.10.0070.0448.22
5.1.00.0170.0338.23
5.0.50.0060.0346.70
5.0.40.0110.0266.60
5.0.30.0060.0526.38
5.0.20.0080.0316.34
5.0.10.0100.0296.33
5.0.00.0090.0466.32
4.4.90.0120.0204.77
4.4.80.0060.0234.75
4.4.70.0070.0244.76
4.4.60.0100.0224.76
4.4.50.0050.0264.77
4.4.40.0100.0334.71
4.4.30.0070.0224.76
4.4.20.0100.0214.84
4.4.10.0040.0264.84
4.4.00.0050.0374.76
4.3.110.0140.0174.67
4.3.100.0090.0214.67
4.3.90.0060.0224.63
4.3.80.0050.0344.58
4.3.70.0070.0214.63
4.3.60.0030.0244.63
4.3.50.0050.0244.63
4.3.40.0050.0334.54
4.3.30.0050.0213.29
4.3.20.0030.0233.26
4.3.10.0060.0193.23
4.3.00.0130.02010.30

preferences:
38.56 ms | 401 KiB | 5 Q