3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Test; class SegmentContainer { private $fooSegmentArray = []; private $barSegmentArray = []; public function __construct(array $fooSegmentArray, array $barSegmentArray) { $this->fooSegmentArray = $fooSegmentArray; $this->barSegmentArray = $barSegmentArray; } public function popFooSegment() { return array_pop($this->fooSegmentArray); } public function shiftBarSegment() { return array_shift($this->barSegmentArray); } } /** * I provide a unified interface to reading the segments, one at a time */ interface SegmentReaderInterface { function readSegment(); } /** * I encapsulate a SegmentContainer, my derivatives determine how to * read from it. */ abstract class SegmentReaderBase implements SegmentReaderInterface { private $segmentContainer; public function __construct(SegmentContainer $segmentContainer) { $this->segmentContainer = $segmentContainer; } public function getSegmentContainer() { return $this->segmentContainer; } } class FooSegmentReader extends SegmentReaderBase { public function readSegment() { return $this->getSegmentContainer()->popFooSegment(); } } class BarSegmentReader extends SegmentReaderBase { public function readSegment() { return $this->getSegmentContainer()->shiftBarSegment(); } } /** * I don't care whether I end up reading from the $fooSegmentArray or * the $barSegmentArray, nor the direction from which I'm reading it. * I just want to be able to read them, one at a time. */ function acceptSegmentReader(SegmentReaderInterface $segmentReader) { var_dump($segmentReader->readSegment()); var_dump($segmentReader->readSegment()); } $segmentContainer = new SegmentContainer(['a', 'b', 'c'], ['1', '2', '3']); acceptSegmentReader(new FooSegmentReader($segmentContainer)); acceptSegmentReader(new BarSegmentReader($segmentContainer)); var_dump($segmentContainer);

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)
8.3.60.0140.00718.20
8.3.50.0090.01121.14
8.3.40.0070.01418.90
8.3.30.0000.01718.96
8.3.20.0080.00020.24
8.3.10.0050.00321.95
8.3.00.0000.00722.46
8.2.180.0080.00818.54
8.2.170.0110.00422.96
8.2.160.0100.00720.55
8.2.150.0080.00024.18
8.2.140.0000.01024.66
8.2.130.0100.00726.16
8.2.120.0050.00319.77
8.2.110.0070.00322.26
8.2.100.0040.00817.77
8.2.90.0000.00819.09
8.2.80.0050.00317.97
8.2.70.0030.00617.50
8.2.60.0040.00417.68
8.2.50.0040.00418.07
8.2.40.0060.00318.09
8.2.30.0050.00318.05
8.2.20.0040.00417.65
8.2.10.0040.00417.68
8.2.00.0030.00717.50
8.1.280.0110.00425.92
8.1.270.0050.00320.31
8.1.260.0000.00726.35
8.1.250.0000.00828.09
8.1.240.0060.00322.47
8.1.230.0090.00317.45
8.1.220.0060.00317.74
8.1.210.0040.00418.77
8.1.200.0070.00317.38
8.1.190.0030.00617.22
8.1.180.0000.00818.99
8.1.170.0060.00318.66
8.1.160.0000.00722.05
8.1.150.0030.00518.68
8.1.140.0050.00217.39
8.1.130.0030.00317.82
8.1.120.0000.00817.48
8.1.110.0040.00417.53
8.1.100.0000.00717.52
8.1.90.0020.00517.47
8.1.80.0070.00017.46
8.1.70.0030.00317.35
8.1.60.0060.00317.62
8.1.50.0080.00017.54
8.1.40.0050.00317.48
8.1.30.0040.00417.69
8.1.20.0000.00817.65
8.1.10.0090.00017.47
8.1.00.0090.00317.38
8.0.300.0000.00718.77
8.0.290.0000.00816.63
8.0.280.0030.00318.40
8.0.270.0030.00317.26
8.0.260.0000.00616.76
8.0.250.0070.00017.00
8.0.240.0000.00817.05
8.0.230.0040.00417.05
8.0.220.0000.00716.97
8.0.210.0030.00316.94
8.0.200.0000.00716.93
8.0.190.0070.00317.00
8.0.180.0030.00417.02
8.0.170.0040.00416.86
8.0.160.0000.00716.92
8.0.150.0030.00416.94
8.0.140.0000.00916.88
8.0.130.0000.00613.26
8.0.120.0000.00716.91
8.0.110.0000.00816.81
8.0.100.0030.00516.84
8.0.90.0040.00416.88
8.0.80.0030.01417.01
8.0.70.0040.00416.75
8.0.60.0060.00316.91
8.0.50.0040.00417.02
8.0.30.0090.01017.13
8.0.20.0060.01217.40
8.0.10.0040.00417.01
8.0.00.0080.01116.83
7.4.330.0030.00315.00
7.4.320.0030.00316.46
7.4.300.0000.00616.65
7.4.290.0040.00416.52
7.4.280.0070.00016.64
7.4.270.0030.00316.61
7.4.260.0040.00416.49
7.4.250.0000.00716.54
7.4.240.0040.00416.61
7.4.230.0030.00316.67
7.4.220.0040.01516.71
7.4.210.0070.00916.58
7.4.200.0040.00316.62
7.4.190.0030.00516.74
7.4.160.0040.01216.42
7.4.150.0060.01217.40
7.4.140.0140.00617.86
7.4.130.0070.01016.58
7.4.120.0110.00716.59
7.4.110.0090.00916.49
7.4.100.0100.00716.55
7.4.90.0070.01016.50
7.4.80.0120.00619.39
7.4.70.0140.00416.52
7.4.60.0060.01016.63
7.4.50.0000.00816.51
7.4.40.0100.00722.77
7.4.30.0100.00616.56
7.4.10.0100.01014.88
7.4.00.0040.00914.89
7.3.330.0000.00613.18
7.3.320.0000.00513.32
7.3.310.0020.00516.32
7.3.300.0040.00416.36
7.3.290.0070.01416.30
7.3.280.0060.01016.28
7.3.270.0090.01017.40
7.3.260.0190.00016.47
7.3.250.0070.01216.32
7.3.240.0160.01016.58
7.3.230.0120.00616.39
7.3.210.0090.00916.38
7.3.200.0090.00919.39
7.3.190.0130.01016.46
7.3.180.0070.01116.48
7.3.170.0100.00716.51
7.3.160.0000.01616.46
7.3.130.0070.01114.86
7.3.120.0050.01014.84
7.3.110.0050.01014.88
7.3.100.0100.00714.85
7.3.90.0050.00714.88
7.3.80.0030.00914.89
7.3.70.0100.00314.74
7.3.60.0080.00814.88
7.3.50.0060.00714.88
7.3.40.0030.01014.78
7.3.30.0070.00914.78
7.3.20.0060.00816.65
7.3.10.0060.00716.45
7.3.00.0050.00816.52
7.2.330.0120.00616.84
7.2.320.0170.00016.42
7.2.310.0100.01316.69
7.2.300.0100.01316.56
7.2.290.0130.00316.57
7.2.260.0000.01915.27
7.2.250.0100.00815.16
7.2.240.0070.01215.06
7.2.230.0110.00814.98
7.2.220.0090.00415.02
7.2.210.0030.00914.84
7.2.200.0040.00615.18
7.2.190.0080.00814.88
7.2.180.0030.01415.23
7.2.170.0080.00615.12
7.2.160.0130.00315.02
7.2.150.0070.00717.00
7.2.140.0040.00717.01
7.2.130.0030.01316.77
7.2.120.0050.00517.01
7.2.110.0030.01016.78
7.2.100.0040.01116.70
7.2.90.0100.00616.98
7.2.80.0000.01616.65
7.2.70.0030.00616.93
7.2.60.0060.00816.83
7.2.50.0070.01017.03
7.2.40.0120.00316.67
7.2.30.0080.00416.87
7.2.20.0070.01116.87
7.2.10.0070.00716.84
7.2.00.0050.00718.22
7.1.330.0020.01215.81
7.1.320.0060.00615.63
7.1.310.0050.00815.88
7.1.300.0100.00515.76
7.1.290.0090.00615.65
7.1.280.0050.00515.85
7.1.270.0060.00815.57
7.1.260.0070.00915.82
7.1.250.0100.00315.59
7.1.240.0000.01315.60
7.1.230.0030.01115.91
7.1.220.0030.00615.49
7.1.210.0000.01215.87
7.1.200.0060.00715.67
7.1.190.0030.00615.61
7.1.180.0030.01215.84
7.1.170.0000.01115.48
7.1.160.0060.00915.89
7.1.150.0080.00415.89
7.1.140.0090.00315.88
7.1.130.0080.00815.65
7.1.120.0070.00315.75
7.1.110.0060.00915.77
7.1.100.0000.00915.76
7.1.90.0070.00715.59
7.1.80.0100.00715.48
7.1.70.0060.00616.30
7.1.60.0000.01216.27
7.1.50.0140.00516.17
7.1.40.0060.00615.82
7.1.30.0080.00615.46
7.1.20.0080.00615.95
7.1.10.0040.00815.55
7.1.00.0040.03219.16
7.0.330.0040.01115.54
7.0.320.0060.00615.36
7.0.310.0070.00715.39
7.0.300.0040.01515.40
7.0.290.0030.01015.39
7.0.280.0080.00315.44
7.0.270.0060.00615.37
7.0.260.0000.01415.51
7.0.250.0040.00815.59
7.0.240.0030.00715.21
7.0.230.0000.01215.61
7.0.220.0120.00315.34
7.0.210.0000.00915.27
7.0.200.0030.00916.01
7.0.190.0070.00715.44
7.0.180.0000.01315.37
7.0.170.0110.00315.32
7.0.160.0040.00815.55
7.0.150.0060.00615.50
7.0.140.0080.03818.67
7.0.130.0100.00715.60
7.0.120.0000.01415.44
7.0.110.0030.00915.23
7.0.100.0070.00715.51
7.0.90.0060.00315.26
7.0.80.0030.01315.10
7.0.70.0030.01015.52
7.0.60.0020.02817.77
7.0.50.0080.04516.78
7.0.40.0100.04116.89
7.0.30.0140.03016.70
7.0.20.0130.03116.80
7.0.10.0150.04316.98
7.0.00.0000.03016.74
5.6.400.0000.01914.22
5.6.390.0100.00714.30
5.6.380.0100.00314.32
5.6.370.0030.01014.34
5.6.360.0090.00614.11
5.6.350.0060.01214.61
5.6.340.0040.00414.51
5.6.330.0100.00314.61
5.6.320.0000.01014.19
5.6.310.0070.00714.27
5.6.300.0030.01014.45
5.6.290.0090.00614.64
5.6.280.0050.04017.89
5.6.270.0040.01114.36
5.6.260.0110.00314.36
5.6.250.0060.00914.45
5.6.240.0030.01114.21
5.6.230.0040.01114.45
5.6.220.0030.00714.22
5.6.210.0090.04217.44
5.6.200.0130.04116.40
5.6.190.0020.04717.45
5.6.180.1940.02317.37
5.6.170.0140.04117.44
5.6.160.0020.03317.43
5.6.150.0040.04416.20
5.6.140.0050.04816.23
5.6.130.0110.03016.33
5.6.120.0020.03517.68
5.6.110.0090.04417.58
5.6.100.0050.05117.58
5.6.90.0030.03017.70
5.6.80.0050.04217.40
5.6.70.0120.02317.24
5.6.60.0060.00914.55
5.6.50.0070.01014.02
5.6.40.0070.00714.43
5.6.30.0030.00914.34
5.6.20.0110.00314.31
5.6.10.0090.00614.11
5.6.00.0120.00014.39
5.5.380.0040.00414.31
5.5.370.0110.00414.48
5.5.360.0070.00714.15
5.5.350.0130.04517.36
5.5.340.0060.02116.30
5.5.330.0100.04317.30
5.5.320.0120.03417.34
5.5.310.0180.04217.45
5.5.300.0050.02216.05
5.5.290.0030.03315.99
5.5.280.0010.04317.63
5.5.270.0020.04917.52
5.5.260.0100.04417.52
5.5.250.0080.04517.46
5.5.240.0050.04417.30
5.5.230.0070.01013.97
5.5.220.0030.01114.43
5.5.210.0000.01114.13
5.5.200.0080.00614.29
5.5.190.0080.00614.34
5.5.180.0000.01414.14
5.5.170.0060.00614.16
5.5.160.0040.00714.28
5.5.150.0030.01214.41
5.5.140.0070.01014.27
5.5.130.0060.00914.30
5.5.120.0040.00814.48
5.5.110.0040.00714.02
5.5.100.0030.01214.20
5.5.90.0100.00714.18
5.5.80.0030.01313.91
5.5.70.0070.00714.20
5.5.60.0090.00614.29
5.5.50.0100.00314.30
5.5.40.0000.01513.84
5.5.30.0000.01214.18
5.5.20.0090.00914.34
5.5.10.0000.01513.81
5.5.00.0050.00514.48
5.4.450.0380.03015.31
5.4.440.0370.04015.41
5.4.430.0490.03715.36
5.4.420.0130.03415.32
5.4.410.0020.03515.17
5.4.400.0150.03415.05
5.4.390.0170.03214.90
5.4.380.0200.04015.01
5.4.370.0100.02714.89
5.4.360.0100.03015.06
5.4.350.0040.02211.65
5.4.340.0070.02111.65
5.4.330.0080.00311.27
5.4.320.0060.02011.89
5.4.310.0040.02711.89
5.4.300.0050.02311.89
5.4.290.0050.02311.89
5.4.280.0060.02611.84
5.4.270.0060.02311.84
5.4.260.0050.02011.84
5.4.250.0060.02715.12
5.4.240.0090.02815.14
5.4.230.0030.03515.05
5.4.220.0030.03515.08
5.4.210.0060.04215.13
5.4.200.0050.03815.03
5.4.190.0080.03815.13
5.4.180.0050.04315.11
5.4.170.0030.03015.13
5.4.160.0060.02815.10
5.4.150.0050.03015.17
5.4.140.0040.02813.82
5.4.130.0000.02913.95
5.4.120.0040.02613.95
5.4.110.0080.02413.97
5.4.100.0070.02413.87
5.4.90.0100.02313.93
5.4.80.0030.03013.86
5.4.70.0050.03113.90
5.4.60.0050.02513.86
5.4.50.0080.02513.90
5.4.40.0020.03213.81
5.4.30.0030.02813.82
5.4.20.0050.02713.89
5.4.10.0030.03113.93
5.4.00.0040.02913.57
5.3.290.0060.02212.03
5.3.280.0080.02712.92
5.3.270.0050.03113.00
5.3.260.0130.02312.97
5.3.250.0050.02512.85
5.3.240.0100.02512.93
5.3.230.0020.02912.96
5.3.220.0050.02813.02
5.3.210.0070.02512.92
5.3.200.0050.02812.95
5.3.190.0040.02813.02
5.3.180.0020.03212.95
5.3.170.0050.02512.96
5.3.160.0110.03312.83
5.3.150.0060.02613.00
5.3.140.0110.02812.90
5.3.130.0070.02613.01
5.3.120.0060.02812.90
5.3.110.0060.02812.95
5.3.100.0020.02912.64
5.3.90.0020.02912.63
5.3.80.0090.02312.68
5.3.70.0060.02712.65
5.3.60.0080.02412.59
5.3.50.0030.02812.64
5.3.40.0040.03712.52
5.3.30.0060.02612.62
5.3.20.0050.03712.43
5.3.10.0020.03012.52
5.3.00.0000.03212.50
5.2.170.0030.04711.14
5.2.160.0030.04011.16
5.2.150.0000.04311.03
5.2.140.0030.04311.02
5.2.130.0100.03310.93
5.2.120.0030.04011.20
5.2.110.0030.05311.20
5.2.100.0000.04010.86
5.2.90.0000.04311.01
5.2.80.0030.04311.11
5.2.70.0000.04310.85
5.2.60.0130.05310.94
5.2.50.0100.03311.04
5.2.40.0030.04010.88
5.2.30.0000.04310.99
5.2.20.0030.04010.95
5.2.10.0100.03010.93
5.2.00.0030.04710.48
5.1.60.0030.0339.85
5.1.50.0130.0239.91
5.1.40.0130.0409.91
5.1.30.0030.03310.55
5.1.20.0030.03710.57
5.1.10.0000.03710.09
5.1.00.0030.03710.16
5.0.50.0070.0208.46
5.0.40.0070.0238.60
5.0.30.0000.0438.27
5.0.20.0030.0238.18
5.0.10.0030.0238.08
5.0.00.0070.0377.98
4.4.90.0000.0206.55
4.4.80.0030.0306.55
4.4.70.0000.0206.55
4.4.60.0000.0306.55
4.4.50.0000.0206.55
4.4.40.0000.0336.55
4.4.30.0000.0206.55
4.4.20.0030.0206.55
4.4.10.0100.0136.55
4.4.00.0000.0376.55
4.3.110.0000.0236.55
4.3.100.0030.0176.55
4.3.90.0000.0206.55
4.3.80.0030.0306.55
4.3.70.0000.0206.55
4.3.60.0000.0206.55
4.3.50.0000.0206.55
4.3.40.0030.0306.55
4.3.30.0000.0236.55
4.3.20.0030.0206.55
4.3.10.0000.0236.55
4.3.00.0170.0208.38

preferences:
36.21 ms | 401 KiB | 5 Q