3v4l.org

run code in 300+ PHP versions simultaneously
<?php class inConstruct { function __construct($array) { foreach ($array as $key => $value) { if ($key == 100) { echo "Done"; } } } } class inMethod { function __construct($array) { $this->doThat($array); } function doThat($array){ foreach ($array as $key => $value) { if ($key == 100) { echo "Done"; } } } } $questions = range("a", "z", 1); for($i=0;$i<10;$i++) {} $start = microtime(); ## For inMethod for ($i=0; $i < 1000; $i++) { $m = new inConstruct($questions); unset($m); } echo (microtime() - $start); echo "\n"; $start = microtime(); ## For inConstruct for ($i=0; $i < 1000; $i++) { $m = new inMethod($questions); unset($m); } echo (microtime() - $start);

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.0070.01716.06
7.3.00.0090.00616.41
7.2.130.0130.00716.77
7.2.120.0060.01316.92
7.2.110.0130.01016.85
7.2.100.0070.01716.75
7.2.90.0120.00817.09
7.2.80.0160.00816.82
7.2.70.0100.00516.50
7.2.60.0130.00316.80
7.2.50.0100.00716.29
7.2.40.0090.00916.84
7.2.30.0070.01116.71
7.2.20.0040.01516.92
7.2.10.0130.00616.71
7.2.00.0070.01016.56
7.1.250.0090.01915.61
7.1.70.0030.00617.34
7.1.60.0100.01619.57
7.1.50.0070.01816.86
7.1.00.0100.07322.31
7.0.200.0070.01116.88
7.0.140.0000.05322.02
7.0.60.0100.07720.05
7.0.50.0030.06017.89
7.0.40.0100.08320.27
7.0.30.0330.08720.06
7.0.20.0130.07320.07
7.0.10.0100.08320.30
7.0.00.0070.08720.29
5.6.280.0030.07320.91
5.6.210.0100.08720.67
5.6.200.0130.07718.18
5.6.190.0000.05320.49
5.6.180.0330.05720.68
5.6.170.0230.04720.50
5.6.160.0030.07020.61
5.6.150.0070.08318.29
5.6.140.0070.07018.18
5.6.130.0070.04018.30
5.6.120.0070.06021.00
5.6.110.0030.06721.02
5.6.100.0130.05721.02
5.6.90.0000.04720.99
5.6.80.0070.04020.45
5.5.350.0270.06720.54
5.5.340.0030.06018.04
5.5.330.0070.05720.45
5.5.320.1970.05720.20
5.5.310.0400.08020.27
5.5.300.0070.04317.96
5.5.290.0130.04318.07
5.5.280.0030.06320.88
5.5.270.0030.04720.86
5.5.260.0030.05020.97
5.5.250.0130.05320.63
5.5.240.0370.07320.25
5.4.450.3100.05319.29
5.4.440.3170.04319.51
5.4.430.3200.04719.38
5.4.420.1330.04719.61
5.4.410.0030.09319.39
5.4.400.0130.07718.87
5.4.390.2430.04719.03
5.4.380.2570.04318.83
5.4.370.3170.05018.99
5.4.360.3130.04719.20
5.4.350.3030.03719.15
5.4.340.2930.04318.99
5.4.320.2530.03019.07
5.4.310.0000.04319.21
5.4.300.0130.06019.17
5.4.290.1000.04718.98
5.4.280.2900.04018.83
5.4.270.2970.04319.29
5.4.260.2930.03718.97
5.4.250.3030.04319.17
5.4.240.3030.04018.82
5.4.230.3100.04319.20
5.4.220.3130.04018.98
5.4.210.2900.04019.05
5.4.200.2930.04719.14
5.4.190.2930.04719.18
5.4.180.3170.04319.16
5.4.170.2730.03319.20
5.4.160.3500.04319.03
5.4.150.2770.04319.18
5.4.140.3070.04016.46
5.4.130.3100.04316.50
5.4.120.2870.04016.49
5.4.110.3170.03316.38
5.4.100.3170.03716.61
5.4.90.3230.03716.24
5.4.80.3170.03716.58
5.4.70.2900.04016.48
5.4.60.2830.04016.43
5.4.50.3030.04016.25
5.4.40.2800.03716.32
5.4.30.3200.04716.43
5.4.20.3170.03716.52
5.4.10.3000.04316.36
5.4.00.3070.04715.88
5.3.290.3170.05014.64
5.3.280.2770.04014.68
5.3.270.3330.04714.61
5.3.260.3070.04714.58
5.3.250.3370.05014.60
5.3.240.3130.04314.63
5.3.230.2970.03314.72
5.3.220.2830.04314.47
5.3.210.3000.03714.66
5.3.200.3100.04714.54
5.3.190.3070.04314.48
5.3.180.2830.04314.57
5.3.170.3130.04014.48
5.3.160.2930.04314.65
5.3.150.2900.04714.69
5.3.140.2930.04014.46
5.3.130.3000.03714.64
5.3.120.2900.04314.63
5.3.110.2930.04314.64
5.3.100.2930.04714.10
5.3.90.3000.03714.00
5.3.80.2970.03713.95
5.3.70.2970.03714.10
5.3.60.3330.04013.91
5.3.50.3400.04314.01
5.3.40.2930.03713.93
5.3.30.2500.03314.00
5.3.20.2900.04013.62
5.3.10.2870.04313.66
5.3.00.3530.05013.72
5.2.170.2600.03311.07
5.2.160.2400.03311.08
5.2.150.3000.04011.11
5.2.140.2470.03311.07
5.2.130.2430.04011.26
5.2.120.2300.02311.12
5.2.110.2370.04011.11
5.2.100.2530.02711.04
5.2.90.2470.03011.16
5.2.80.2800.05011.05
5.2.70.2230.03011.03
5.2.60.2430.03010.99
5.2.50.2430.04311.07
5.2.40.1870.04011.01
5.2.30.1670.04011.06
5.2.20.1930.03310.93
5.2.10.2000.03310.82
5.2.00.1530.03310.70
5.1.60.2100.03310.09
5.1.50.2200.0339.95
5.1.40.2170.0409.95
5.1.30.2200.03710.57
5.1.20.2200.03310.37
5.1.10.2200.04010.16
5.1.00.2200.03010.05
5.0.50.1230.0338.50
5.0.40.1170.0478.39
5.0.30.1270.0508.22
5.0.20.1300.0408.09
5.0.10.1170.0508.27
5.0.00.1230.0538.09
4.4.90.1000.0136.73
4.4.80.1130.0206.73
4.4.70.1170.0176.73
4.4.60.1170.0176.73
4.4.50.1000.0176.73
4.4.40.0970.0276.73
4.4.30.1170.0206.73
4.4.20.0970.0176.73
4.4.10.1170.0206.73
4.4.00.1030.0276.73
4.3.110.1000.0136.73
4.3.100.0970.0176.73
4.3.90.1000.0136.73
4.3.80.1030.0236.73
4.3.70.1000.0136.73
4.3.60.1070.0176.73
4.3.50.0970.0176.73
4.3.40.1030.0236.73
4.3.30.0500.0136.73
4.3.20.0500.0176.73
4.3.10.0470.0176.73
4.3.00.0500.0176.73

preferences:
29.69 ms | 401 KiB | 5 Q