3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Image { public function __construct($path) { $this->image = imagecreatefromjpeg($path); } public function getSize() { return array(imagesx($this->image), imagesy($this->image)); } } class ImageProxy extends Image { protected $image; public function __construct($path) { $this->path = $path; } private function init() { if ( ! $this->image) { $this->image = new Image($this->path); } } public function getSize() { $this->init(); return $this->image->getSize(); } } $img1 = new ImageProxy('/path/to/image1.jpg'); var_dump(memory_get_usage()); // ~200Kb $img2 = new ImageProxy('/path/to/image2.jpg'); var_dump(memory_get_usage()); // ~200Kb $img3 = new ImageProxy('/path/to/image3.jpg'); var_dump(memory_get_usage()); // ~200Kb $size1 = $img1->getSize(); var_dump(memory_get_usage()); // ~4Mb $size2 = $img2->getSize(); var_dump(memory_get_usage()); // ~8Mb

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.10.0100.00515.05
7.4.00.0070.01114.99
7.3.130.0050.01114.84
7.3.120.0070.00914.84
7.3.110.0120.00514.82
7.3.100.0120.00214.83
7.3.90.0070.00614.87
7.3.80.0060.00714.82
7.3.70.0080.00614.78
7.3.60.0030.01214.73
7.3.50.0070.00514.86
7.3.40.0030.00714.87
7.3.30.0070.00814.89
7.3.20.0040.00716.56
7.3.10.0040.00816.56
7.3.00.0060.00716.56
7.2.260.0070.01114.89
7.2.250.0100.00714.99
7.2.240.0100.00615.00
7.2.230.0090.00714.96
7.2.220.0060.00815.25
7.2.210.0090.00615.00
7.2.200.0070.00315.18
7.2.190.0120.00315.12
7.2.180.0090.00615.25
7.2.170.0070.00515.16
7.2.160.0070.00714.84
7.2.150.0050.00816.55
7.2.140.0070.00616.88
7.2.130.0060.00716.72
7.2.120.0030.01017.01
7.2.110.0080.00716.97
7.2.100.0030.01016.74
7.2.90.0060.00817.05
7.2.80.0050.00916.92
7.2.70.0040.00816.99
7.2.60.0020.01116.83
7.2.50.0040.00917.02
7.2.40.0090.00616.76
7.2.30.0070.01016.82
7.2.20.0040.01016.99
7.2.10.0060.00916.86
7.2.00.0080.00716.90
7.1.330.0050.00915.71
7.1.320.0060.00715.66
7.1.310.0060.00715.68
7.1.300.0070.00715.53
7.1.290.0040.00815.63
7.1.280.0020.01015.60
7.1.270.0060.00915.71
7.1.260.0030.00915.58
7.1.250.0100.00415.62
7.1.240.0050.00915.63
7.1.230.0050.01015.69
7.1.220.0050.00815.63
7.1.210.0060.00715.77
7.1.200.0020.01415.72
7.1.190.0030.00815.57
7.1.180.0060.00815.63
7.1.170.0050.00815.76
7.1.160.0050.01015.60
7.1.150.0080.00815.78
7.1.140.0060.00815.85
7.1.130.0060.00615.74
7.1.120.0030.01015.54
7.1.110.0000.01215.78
7.1.100.0060.00715.66
7.1.90.0060.00715.51
7.1.80.0100.00515.61
7.1.70.0040.00816.12
7.1.60.0090.00716.89
7.1.50.0080.00916.02
7.1.40.0020.01015.82
7.1.30.0040.00515.56
7.1.20.0060.00615.54
7.1.10.0070.00915.57
7.1.00.0030.01917.95
7.0.330.0070.00415.19
7.0.320.0050.00715.46
7.0.310.0070.00415.30
7.0.300.0040.01015.14
7.0.290.0070.00515.29
7.0.280.0050.00715.21
7.0.270.0060.00615.36
7.0.260.0090.00315.51
7.0.250.0060.01015.52
7.0.240.0060.00915.52
7.0.230.0020.00915.49
7.0.220.0050.00815.36
7.0.210.0080.00215.38
7.0.200.0030.00915.79
7.0.190.0050.00915.48
7.0.180.0080.00715.36
7.0.170.0020.00915.37
7.0.160.0070.00715.54
7.0.150.0050.00715.52
7.0.140.0050.02817.65
7.0.130.0070.00815.29
7.0.120.0060.00615.31
7.0.110.0070.00715.32
7.0.100.0020.01115.36
7.0.90.0100.00515.39
7.0.80.0030.00915.29
7.0.70.0030.03017.56
7.0.60.0060.02417.53
7.0.50.0110.02917.67
7.0.40.0050.02715.89
7.0.30.0020.03715.95
7.0.20.0050.03415.84
7.0.10.0030.03515.89
7.0.00.0080.02615.87
5.6.400.0060.00914.31
5.6.390.0080.00614.34
5.6.380.0060.00814.24
5.6.370.0080.00614.25
5.6.360.0060.00814.37
5.6.350.0030.01314.29
5.6.340.0050.00914.18
5.6.330.0070.00714.48
5.6.320.0020.01314.51
5.6.310.0050.00414.34
5.6.300.0060.00714.14
5.6.290.0050.00614.61
5.6.280.0040.03316.68
5.6.270.0030.01214.40
5.6.260.0050.01014.33
5.6.250.0080.00214.41
5.6.240.0020.01314.33
5.6.230.0050.00814.56
5.6.220.0040.02316.46
5.6.210.0040.03216.43
5.6.200.0090.03216.64
5.6.190.0070.03216.57
5.6.180.0040.03116.52
5.6.170.0070.03116.63
5.6.160.0060.02016.67
5.6.150.0090.03016.69
5.6.140.0070.03416.68
5.6.130.0040.02616.60
5.6.120.0060.02316.62
5.6.110.0060.03116.46
5.6.100.0050.03116.64
5.6.90.0040.03116.67
5.6.80.0090.02516.42
5.6.70.0060.02816.38
5.6.60.0070.03116.33
5.6.50.0070.03016.31
5.6.40.0030.02716.31
5.6.30.0070.02716.29
5.6.20.0070.02516.31
5.6.10.0040.03116.25
5.6.00.0050.02616.35
5.5.380.0060.00614.15
5.5.370.0040.00614.29
5.5.360.0070.03116.38
5.5.350.0060.03016.14
5.5.340.0070.01716.39
5.5.330.0060.02916.29
5.5.320.0040.03616.34
5.5.310.0060.03216.34
5.5.300.0040.02416.54
5.5.290.0020.03416.35
5.5.280.0030.03416.46
5.5.270.0060.03216.42
5.5.260.0070.02916.30
5.5.250.0020.03416.29
5.5.240.0050.03316.27
5.5.230.0070.03216.08
5.5.220.0090.02816.24
5.5.210.0070.03316.10
5.5.200.0110.02716.13
5.5.190.0070.03216.31
5.5.180.0050.03516.24
5.5.170.0070.00414.23
5.5.160.0080.02716.14
5.5.150.0030.03516.07
5.5.140.0100.03016.14
5.5.130.0070.03316.15
5.5.120.0060.02116.24
5.5.110.0050.03115.99
5.5.100.0090.02716.11
5.5.90.0070.02516.23
5.5.80.0060.03316.22
5.5.70.0080.03316.33
5.5.60.0060.02716.21
5.5.50.0080.02816.23
5.5.40.0060.02316.22
5.5.30.0070.02916.26
5.5.20.0060.02616.06
5.5.10.0040.03016.22
5.5.00.0050.03416.13
5.4.450.0010.02814.80
5.4.440.0050.02014.71
5.4.430.0050.01914.71
5.4.420.0030.02714.86
5.4.410.0010.02614.76
5.4.400.0060.02914.64
5.4.390.0050.02914.52
5.4.380.0030.02314.70
5.4.370.0040.02714.71
5.4.360.0080.02514.79
5.4.350.0040.02214.69
5.4.340.0040.03014.65
5.4.330.0030.00912.54
5.4.320.0100.02714.65
5.4.310.0050.03014.68
5.4.300.0040.02114.59
5.4.290.0050.02314.73
5.4.280.0080.02314.67
5.4.270.0050.01614.72
5.4.260.0080.02114.66
5.4.250.0060.02814.71
5.4.240.0050.02814.70
5.4.230.0040.02014.62
5.4.220.0060.02814.55
5.4.210.0060.02014.60
5.4.200.0020.02314.62
5.4.190.0080.02714.54
5.4.180.0030.03114.62
5.4.170.0000.03114.72
5.4.160.0060.02314.65
5.4.150.0070.02814.59
5.4.140.0030.02913.85
5.4.130.0020.02913.91
5.4.120.0060.02713.85
5.4.110.0060.02913.84
5.4.100.0040.02913.77
5.4.90.0030.03213.87
5.4.80.0040.02713.75
5.4.70.0040.02913.71
5.4.60.0050.02013.78
5.4.50.0030.01713.75
5.4.40.0030.02913.88
5.4.30.0060.02513.77
5.4.20.0030.02213.81
5.4.10.0020.02213.76
5.4.00.0020.02613.58
5.3.290.0070.02813.19
5.3.280.0010.03313.08
5.3.270.0060.02013.01
5.3.260.0040.03013.08
5.3.250.0030.02813.06
5.3.240.0040.03113.09
5.3.230.0050.02313.08
5.3.220.0060.02713.08
5.3.210.0010.03513.07
5.3.200.0070.01713.03
5.3.190.0060.02713.06
5.3.180.0050.02413.13
5.3.170.0040.02613.04
5.3.160.0020.02713.15
5.3.150.0040.01713.11
5.3.140.0030.02813.10
5.3.130.0110.02313.04
5.3.120.0070.02913.10
5.3.110.0020.02013.13
5.3.100.0030.02812.87
5.3.90.0050.02612.92
5.3.80.0040.02812.95
5.3.70.0010.03012.86
5.3.60.0030.02812.87
5.3.50.0050.02312.87
5.3.40.0020.03212.84
5.3.30.0030.02312.84
5.3.20.0020.02912.71
5.3.10.0070.01812.66
5.3.00.0040.02512.73
5.2.170.0070.06012.26
5.2.160.0070.06012.26
5.2.150.0000.05712.26
5.2.140.0000.06712.26
5.2.130.0030.06312.26
5.2.120.0070.03712.26
5.2.110.0100.05712.26
5.2.100.0030.06012.26
5.2.90.0100.04712.26
5.2.80.0200.04712.26
5.2.70.0070.05312.26
5.2.60.0030.05312.26
5.2.50.0070.06012.26
5.2.40.0030.04012.26
5.2.30.0030.06312.26
5.2.20.0170.03712.26
5.2.10.0070.06012.26
5.2.00.0030.06012.26
5.1.60.0000.05312.26
5.1.50.0000.04312.26
5.1.40.0030.05312.26
5.1.30.0070.05712.26
5.1.20.0030.05012.26
5.1.10.0070.05012.26
5.1.00.0070.03712.26
5.0.50.0030.04712.26
5.0.40.0070.04012.26
5.0.30.0000.05712.26
5.0.20.0070.03712.26
5.0.10.0000.04312.26
5.0.00.0100.05312.26
4.4.90.0070.02012.26
4.4.80.0030.03312.26
4.4.70.0000.03312.26
4.4.60.0000.03712.26
4.4.50.0070.03012.26
4.4.40.0000.05712.26
4.4.30.0000.03712.26
4.4.20.0030.02012.26
4.4.10.0030.03312.26
4.4.00.0030.05312.26
4.3.110.0070.02712.26
4.3.100.0030.03312.26
4.3.90.0030.03012.26
4.3.80.0070.05012.26
4.3.70.0000.03712.26
4.3.60.0000.03712.26
4.3.50.0030.03312.26
4.3.40.0000.05312.26
4.3.30.0070.03312.26
4.3.20.0030.03012.26
4.3.10.0030.03312.26
4.3.00.0000.04012.26

preferences:
35.38 ms | 400 KiB | 5 Q