3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(); $meanax = 300; for($i = 0; $i < $meanax; $i++) { $array[$i] = rand(0, $meanax-1); echo $array[$i]."\n"; } $s = sd($array); $mean = array_sum($array) / count($array); echo "\nbefore\n"; var_dump(array('s' => $s, 'm' => $mean)); $n = count($array); $x_new = 100000000; $x_quer_strich = m_reverse($n, $mean, $x_new); $s_new = sd_reverse($s, $n, $x_new, $x_quer_strich); echo "\nreverse\n"; var_dump(array('s' => $s_new, 'm' => $x_quer_strich)); $array[$n+1] = $x_new; $s = sd($array); $mean = array_sum($array) / count($array); echo "\nafter\n"; var_dump(array('s' => $s, 'm' => $mean)); // Function to calculate square of value - mean function sd_square($x, $mean) { return pow($x - $mean,2); } // Function to calculate standard deviation (uses sd_square) function sd($array) { // square root of sum of squares devided by N-1 return sqrt(array_sum(array_map("sd_square", $array, array_fill(0,count($array), (array_sum($array) / count($array)) ) ) ) / (count($array)-1) ); } function m_reverse($n, $mean, $x) { return ( $n * $mean + $x ) / ( $n + 1 ); } function sd_reverse($s, $n, $x, $mean) { return sqrt( 1 / $n * ( ( $n - 1 ) * pow( $s, 2 ) + ( $x - $mean ) ) ); }

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.4.00.0110.00314.97
7.3.120.0070.01114.71
7.3.110.0070.01315.32
7.3.100.0030.01315.09
7.3.90.0030.01214.98
7.3.80.0030.01414.80
7.3.70.0070.01115.08
7.3.60.0120.00315.23
7.3.50.0060.00915.00
7.3.40.0070.01315.06
7.3.30.0060.01215.01
7.3.20.0040.01216.88
7.3.10.0120.00416.85
7.3.00.0100.00716.59
7.2.250.0100.01015.25
7.2.240.0130.00715.16
7.2.230.0060.01215.24
7.2.220.0040.01115.40
7.2.210.0110.00415.05
7.2.200.0090.00915.32
7.2.190.0040.00815.34
7.2.180.0030.01615.11
7.2.170.0060.01215.25
7.2.160.0090.00915.23
7.2.150.0130.00317.13
7.2.140.0070.00716.88
7.2.130.0030.01016.85
7.2.120.0100.00717.06
7.2.110.0100.00716.86
7.2.100.0110.00717.00
7.2.90.0030.01317.14
7.2.80.0070.00717.27
7.2.70.0060.00917.15
7.2.60.0040.00817.07
7.2.50.0110.00417.14
7.2.40.0040.01117.22
7.2.30.0070.01016.84
7.2.20.0030.01317.06
7.2.10.0090.00317.15
7.2.00.0100.00716.86
7.1.330.0090.00915.66
7.1.320.0000.01315.95
7.1.310.0060.00916.09
7.1.300.0100.00315.88
7.1.290.0060.00815.93
7.1.280.0120.00315.64
7.1.270.0090.00615.98
7.1.260.0060.01016.05
7.1.250.0090.00815.93
7.1.240.0090.00615.69
7.1.230.0060.01015.59
7.1.220.0040.00815.95
7.1.210.0030.01316.12
7.1.200.0070.00715.98
7.1.190.0060.00616.09
7.1.180.0040.01116.08
7.1.170.0080.00415.89
7.1.160.0030.01015.82
7.1.150.0130.00315.97
7.1.140.0170.00015.95
7.1.130.0000.01516.07
7.1.120.0070.00715.84
7.1.110.0060.00915.92
7.1.100.0070.00715.89
7.1.90.0130.00315.86
7.1.80.0030.00916.01
7.1.70.0030.00716.59
7.1.60.0090.01317.83
7.1.50.0050.00816.56
7.1.40.0100.00316.02
7.1.30.0100.00716.14
7.1.20.0100.00316.05
7.1.10.0040.01116.03
7.1.00.0030.04519.26
7.0.330.0070.01015.38
7.0.320.0070.00415.57
7.0.310.0080.00815.44
7.0.300.0160.00015.50
7.0.290.0070.01115.53
7.0.280.0070.00715.54
7.0.270.0060.00915.47
7.0.260.0100.00315.55
7.0.250.0110.00715.66
7.0.240.0070.00715.54
7.0.230.0030.01015.66
7.0.220.0060.00915.62
7.0.210.0090.00615.33
7.0.200.0080.00916.20
7.0.190.0150.00015.71
7.0.180.0070.00715.59
7.0.170.0060.00915.70
7.0.160.0080.00515.61
7.0.150.0030.01015.42
7.0.140.0050.04018.86
7.0.130.0030.01215.34
7.0.120.0000.01515.64
7.0.110.0030.00915.64
7.0.100.0070.04717.71
7.0.90.0080.04517.82
7.0.80.0070.04417.87
7.0.70.0050.04617.84
7.0.60.0080.04517.74
7.0.50.0100.04217.98
7.0.40.0080.04316.97
7.0.30.0120.04316.82
7.0.20.0020.04817.03
7.0.10.0060.04316.90
7.0.00.0050.04716.89
5.6.400.0140.00314.86
5.6.390.0040.01114.70
5.6.380.0030.01014.74
5.6.370.0030.01314.43
5.6.360.0070.01014.69
5.6.350.0160.00014.66
5.6.340.0030.00914.98
5.6.330.0110.00614.55
5.6.320.0070.00714.86
5.6.310.0110.00414.86
5.6.300.0030.01314.79
5.6.290.0030.01014.30
5.6.280.0100.03617.67
5.6.270.0060.00615.07
5.6.260.0030.01314.71
5.6.250.0090.04317.74
5.6.240.0150.03817.77
5.6.230.0120.04317.76
5.6.220.0100.03917.67
5.6.210.0100.04217.73
5.6.200.0050.05018.00
5.6.190.0050.04417.95
5.6.180.0150.03817.93
5.6.170.0050.03718.06
5.6.160.0070.04617.92
5.6.150.0080.04117.80
5.6.140.0020.05317.96
5.6.130.0090.04317.91
5.6.120.0030.05118.00
5.6.110.0050.04617.95
5.6.100.0100.04717.89
5.6.90.0060.04318.12
5.6.80.0090.04317.47
5.6.70.0160.03517.55
5.6.60.0110.03817.63
5.6.50.0130.04017.79
5.6.40.0080.04617.46
5.6.30.0050.04317.67
5.6.20.0070.04017.66
5.6.10.0150.03517.84
5.6.00.0130.03617.58
5.5.380.0050.04717.58
5.5.370.0030.04617.55
5.5.360.0030.04717.80
5.5.350.0100.04017.51
5.5.340.0090.04317.73
5.5.330.0080.04917.93
5.5.320.0050.04917.84
5.5.310.0080.04517.89
5.5.300.0070.04517.97
5.5.290.0030.05017.93
5.5.280.0100.04017.88
5.5.270.0030.05017.83
5.5.260.0100.04217.88
5.5.250.0080.04317.61
5.5.240.0070.04317.48
5.5.230.0100.04317.39
5.5.220.0140.04017.57
5.5.210.0030.04617.47
5.5.200.0090.04317.32
5.5.190.0080.04617.56
5.5.180.0080.04617.44
5.5.170.0040.01214.46
5.5.160.0100.04317.26
5.5.150.0030.04517.42
5.5.140.0070.04617.50
5.5.130.0170.03617.46
5.5.120.0060.04317.56
5.5.110.0070.04717.56
5.5.100.0110.04017.16
5.5.90.0130.04117.34
5.5.80.0020.04717.38
5.5.70.0080.04517.24
5.5.60.0020.05017.35
5.5.50.0030.04917.29
5.5.40.0090.04317.53
5.5.30.0050.04017.25
5.5.20.0030.04917.51
5.5.10.0080.04117.29
5.5.00.0020.04917.36
5.4.450.0050.03715.58
5.4.440.0100.04015.62
5.4.430.0080.04415.67
5.4.420.0030.04615.62
5.4.410.0050.04215.56
5.4.400.0080.04315.37
5.4.390.0040.04415.36
5.4.380.0070.03315.46
5.4.370.0070.04215.54
5.4.360.0080.03915.46
5.4.350.0050.04215.49
5.4.340.0040.04215.46
5.4.330.0000.01211.71
5.4.320.0060.04115.51
5.4.310.0050.04315.46
5.4.300.0060.04115.46
5.4.290.0080.03815.45
5.4.280.0110.03415.50
5.4.270.0120.03515.49
5.4.260.0060.04215.52
5.4.250.0100.03715.41
5.4.240.0070.04115.46
5.4.230.0100.03715.48
5.4.220.0120.04115.45
5.4.210.0050.04415.52
5.4.200.0050.04315.38
5.4.190.0050.04315.38
5.4.180.0130.03615.48
5.4.170.0070.04015.53
5.4.160.0030.04315.44
5.4.150.0100.03015.40
5.4.140.0080.03914.14
5.4.130.0060.04114.03
5.4.120.0020.04414.10
5.4.110.0050.04514.21
5.4.100.0050.04114.16
5.4.90.0080.03914.14
5.4.80.0080.04114.15
5.4.70.0030.04314.06
5.4.60.0120.03714.12
5.4.50.0050.02514.18
5.4.40.0070.02214.05
5.4.30.0060.02314.14
5.4.20.0040.02414.16
5.4.10.0030.03514.10
5.4.00.0080.02113.88
5.3.290.0110.03713.32
5.3.280.0080.04213.36
5.3.270.0060.04513.33
5.3.260.0110.04013.26
5.3.250.0080.04013.34
5.3.240.0120.03913.28
5.3.230.0070.04113.26
5.3.220.0130.04013.27
5.3.210.0100.04113.33
5.3.200.0070.04413.25
5.3.190.0060.04513.33
5.3.180.0080.04113.25
5.3.170.0080.04013.34
5.3.160.0090.02313.25
5.3.150.0030.05013.26
5.3.140.0090.02213.34
5.3.130.0060.02713.25
5.3.120.0030.02913.30
5.3.110.0070.04113.25
5.3.100.0130.03213.06
5.3.90.0070.02313.06
5.3.80.0070.02012.99
5.3.70.0040.02812.96
5.3.60.0140.03112.96
5.3.50.0080.02312.96
5.3.40.0090.02412.94
5.3.30.0130.03613.01
5.3.20.0060.02312.83
5.3.10.0110.02012.85
5.3.00.0040.03112.85
5.2.170.0000.05711.49
5.2.160.0130.02311.48
5.2.150.0070.04711.37
5.2.140.0030.05311.40
5.2.130.0070.02711.32
5.2.120.0000.03711.50
5.2.110.0030.03311.46
5.2.100.0030.03311.43
5.2.90.0000.03311.34
5.2.80.0030.03011.36
5.2.70.0030.03011.29
5.2.60.0000.05711.39
5.2.50.0100.02711.21
5.2.40.0000.03711.16
5.2.30.0030.06711.15
5.2.20.0070.02711.15
5.2.10.0000.04311.03
5.2.00.0030.03011.07
5.1.60.0000.02710.19
5.1.50.0070.03010.38
5.1.40.0030.03710.38
5.1.30.0030.05310.77
5.1.20.0070.05310.57
5.1.10.0000.02310.44
5.1.00.0000.03310.39
5.0.50.0030.0209.78
5.0.40.0030.0409.78
5.0.30.0030.0479.78
5.0.20.0030.0339.78
5.0.10.0100.0409.78
5.0.00.0030.0639.78
4.4.90.0000.0209.78
4.4.80.0030.0179.78
4.4.70.0070.0309.78
4.4.60.0000.0209.78
4.4.50.0070.0139.78
4.4.40.0030.0479.78
4.4.30.0030.0209.78
4.4.20.0030.0139.78
4.4.10.0030.0239.78
4.4.00.0070.0279.78
4.3.110.0000.0309.78
4.3.100.0030.0279.78
4.3.90.0000.0379.78
4.3.80.0030.0539.78
4.3.70.0000.0379.78
4.3.60.0070.0339.78
4.3.50.0000.0409.78
4.3.40.0030.0539.78
4.3.30.0030.0379.78
4.3.20.0000.0439.78
4.3.10.0030.0379.78
4.3.00.0070.0339.78

preferences:
40.71 ms | 401 KiB | 5 Q