3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('N', 1000); class Redis { public function run($n) { $a = rand($n, 2*$n); } } class A { protected $redis; function __construct() { $this->redis = new Redis(); } function getRedis() { return $this->redis; } function run() { for ($i = 0; $i < N; $i++) { $this->getRedis()->run($i); } } } class B { protected $redis; function __construct() { $this->redis = new Redis(); } function run() { for ($i = 0; $i < N; $i++) { $this->redis->run($i); } } } $time = microtime(true); $a = new A(); $a->run(); $et1 = microtime(true) - $time; print 'Execution time with *property* accessor: ' . $et1 . PHP_EOL; $time = microtime(true); $b = new B(); $b->run(); $et2 = microtime(true) - $time; print 'Execution time *without* property accessor: ' . $et2 . PHP_EOL; print 'Ratio: ' . ($et1/$et2) . PHP_EOL;

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.1.70.0090.00017.25
7.1.60.0030.00716.96
7.1.50.0090.01517.03
7.1.00.0070.06322.40
7.0.200.0040.01216.82
7.0.140.0030.07722.00
7.0.120.0000.08022.16
7.0.60.0030.04020.06
7.0.50.0030.04717.91
7.0.40.0070.04317.86
7.0.30.0070.08317.79
7.0.20.0070.05017.85
7.0.10.0070.08717.68
7.0.00.0100.06317.68
5.6.280.0030.07020.91
5.6.210.0070.03720.48
5.6.200.0030.08718.19
5.6.190.0030.04318.18
5.6.180.0130.06718.19
5.6.170.0070.08318.13
5.6.160.0000.04718.15
5.6.150.0030.08718.28
5.6.140.0230.06318.17
5.6.130.0070.06318.18
5.6.120.0030.04718.25
5.6.110.0130.07718.28
5.6.100.0100.07718.25
5.6.90.0100.08018.12
5.6.80.0030.08017.55
5.6.70.0100.05017.57
5.6.60.0130.07317.60
5.6.50.0030.08017.63
5.6.40.0130.04317.52
5.6.30.0030.04317.59
5.6.20.0100.07717.47
5.6.10.0030.07717.47
5.6.00.0100.08017.53
5.5.350.0170.07720.44
5.5.340.0100.06018.04
5.5.330.0070.06017.98
5.5.320.0030.04717.99
5.5.310.0030.08317.95
5.5.300.0070.08317.93
5.5.290.0070.08717.95
5.5.280.0030.08717.98
5.5.270.0070.08717.98
5.5.260.0070.08717.98
5.5.250.0030.08317.80
5.5.240.0030.06017.38
5.5.230.0170.04717.48
5.5.220.0030.07317.42
5.5.210.0130.07017.33
5.5.200.0070.07717.30
5.5.190.0030.07717.39
5.5.180.0070.07317.34
5.5.160.0000.04317.34
5.5.150.0030.08017.28
5.5.140.0030.08317.34
5.5.130.0030.08317.43
5.5.120.0030.07317.29
5.5.110.0130.07717.43
5.5.100.0070.05017.24
5.5.90.0030.05017.29
5.5.80.0030.05317.33
5.5.70.0070.04717.21
5.5.60.0100.06317.17
5.5.50.0070.05317.29
5.5.40.0070.07717.21
5.5.30.0170.06717.21
5.5.20.0030.04017.32
5.5.10.0130.06317.16
5.5.00.0200.06017.20
5.4.450.0070.04019.43
5.4.440.0130.07319.36
5.4.430.0070.07719.43
5.4.420.0030.07719.46
5.4.410.0070.07719.23
5.4.400.0070.07719.06
5.4.390.0030.05018.98
5.4.380.0030.05019.13
5.4.370.0070.08019.05
5.4.360.0000.08719.13
5.4.350.0100.07319.13
5.4.340.0130.06719.12
5.4.320.0100.03719.03
5.4.310.0130.07019.03
5.4.300.0030.07019.03
5.4.290.0030.05319.02
5.4.280.0170.06719.01
5.4.270.0000.05719.01
5.4.260.0100.07018.88
5.4.250.0100.06319.05
5.4.240.0070.06319.09
5.4.230.0070.07719.11
5.4.220.0130.07319.26
5.4.210.0130.04319.02
5.4.200.0000.05719.09
5.4.190.0100.06319.11
5.4.180.0070.04319.04
5.4.170.0170.06719.11
5.4.160.0030.04719.03
5.4.150.0130.07318.99
5.4.140.0030.05716.59
5.4.130.0100.07316.29
5.4.120.0070.06316.34
5.4.110.0070.07716.37
5.4.100.0070.07716.36
5.4.90.0130.05316.50
5.4.80.0100.04316.44
5.4.70.0030.07316.27
5.4.60.0100.07316.21
5.4.50.0070.07316.38
5.4.40.0030.04016.51
5.4.30.0100.03716.27
5.4.20.0100.07016.32
5.4.10.0030.06716.43
5.4.00.0130.03316.01
5.3.290.0070.07714.89
5.3.280.0100.04014.82
5.3.270.0030.05714.68
5.3.260.0000.08714.61
5.3.250.0070.08314.57
5.3.240.0030.05714.62
5.3.230.0000.05314.46
5.3.220.0070.07314.79
5.3.210.0030.08014.81
5.3.200.0030.05014.61
5.3.190.0100.05014.63
5.3.180.0000.04314.42
5.3.170.0070.07314.59
5.3.160.0200.06714.58
5.3.150.0070.08014.42
5.3.140.0130.06314.61
5.3.130.0070.08014.62
5.3.120.0130.07014.60
5.3.110.0030.06314.54
5.3.100.0030.05714.10
5.3.90.0070.05714.09
5.3.80.0130.04014.08
5.3.70.0070.04314.01
5.3.60.0070.07714.03
5.3.50.0100.07014.00
5.3.40.0070.08014.02
5.3.30.0030.07714.13
5.3.20.0030.04013.78
5.3.10.0070.03313.68
5.3.00.0030.08013.69
5.2.170.0000.04311.07
5.2.160.0030.04011.00
5.2.150.0030.06711.14
5.2.140.0000.07311.16
5.2.130.0130.04311.12
5.2.120.0030.03711.08
5.2.110.0100.05711.22
5.2.100.0030.06311.11
5.2.90.0030.04711.32
5.2.80.0030.03311.11
5.2.70.0000.07011.14
5.2.60.0070.06311.11
5.2.50.0070.06011.03
5.2.40.0000.03710.98
5.2.30.0100.06011.19
5.2.20.0070.05010.87
5.2.10.0030.05010.92
5.2.00.0070.05010.71
5.1.60.0070.02310.08
5.1.50.0070.05710.21
5.1.40.0030.0479.99
5.1.30.0030.05310.41
5.1.20.0100.05710.39
5.1.10.0070.05310.14
5.1.00.0070.04710.07
5.0.50.0030.0379.01
5.0.40.0030.0509.01
5.0.30.0000.0609.01
5.0.20.0000.0509.01
5.0.10.0000.0239.01
5.0.00.0000.0479.01
4.4.90.0070.0339.01
4.4.80.0000.0309.01
4.4.70.0070.0179.01
4.4.60.0000.0409.01
4.4.50.0030.0239.01
4.4.40.0070.0539.01
4.4.30.0030.0339.01
4.4.20.0070.0309.01
4.4.10.0030.0279.01
4.4.00.0030.0379.01
4.3.110.0030.0379.01
4.3.100.0030.0309.01
4.3.90.0000.0279.01
4.3.80.0030.0479.01
4.3.70.0000.0239.01
4.3.60.0030.0209.01
4.3.50.0000.0209.01
4.3.40.0030.0539.01
4.3.30.0030.0239.01
4.3.20.0000.0409.01
4.3.10.0030.0379.01
4.3.00.0000.0309.01

preferences:
36.33 ms | 400 KiB | 5 Q