3v4l.org

run code in 300+ PHP versions simultaneously
<?php class UBuffer implements ArrayAccess, IteratorAggregate, Countable { public function __construct($input) { for ($it = 0; $it < mb_strlen($input); $it++) { $this->buffer[$it] = mb_substr($input, $it, 1); } } public function offsetGet($offset) { return $this->buffer[$offset]; } public function offsetUnset($offset) { throw new RuntimeException("NOPE"); } public function offsetSet($offset, $char) { throw new RuntimeException("NOPE"); } public function offsetExists($offset) { return isset($this->buffer[$offset]); } public function getIterator() { return new ArrayIterator($this->buffer); } public function count() { return count($this->data); } private $buffer; } class UBreaker implements IteratorAggregate, Countable { const KEEP = 1; const NEXT = 2; public function __construct(UBuffer $buffer, Closure $breaker) { $count = 0; $mem = null; foreach ($buffer as $idx => $char) { switch ($breaker($buffer, $idx, $char, $mem)) { case self::KEEP: if (isset($this->buffer[$count])) $this->buffer[$count] .= $char; else $this->buffer[$count] = $char; break; case self::NEXT: $count++; break; } } foreach ($this->buffer as $idx => $value) $this->buffer[$idx] = new UBuffer($value); } public function getIterator() { return new ArrayIterator($this->buffer); } public function count() { return count($this->buffer); } private $buffer; } $buffer = new UBuffer("This is a simple sentence. And here's another one."); $breaker = new UBreaker($buffer, function(UBuffer $buffer, $index, $char, &$mem) { switch ($char) { case " ": switch ($mem) { case ".": case "!": case "?": $mem = $char; return UBreaker::NEXT; } default: $mem = $char; return UBreaker::KEEP; } }); foreach ($breaker as $sentence) { var_dump($sentence); } ?>

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.5.30.0100.00817.42
8.5.20.0130.00419.80
8.5.10.0110.00820.16
8.5.00.0110.01020.24
8.4.180.0120.01025.83
8.4.170.0160.00724.03
8.4.160.0140.01024.02
8.4.150.0090.00417.02
8.4.140.0110.01017.57
8.4.130.0080.00617.84
8.4.120.0110.00920.78
8.4.110.0060.00422.71
8.4.100.0040.00518.11
8.4.90.0110.01018.79
8.4.80.0130.00719.76
8.4.70.0050.00617.78
8.4.60.0130.00818.65
8.4.50.0090.01218.76
8.4.40.0170.00319.44
8.4.30.0110.01117.78
8.4.20.0100.01017.76
8.4.10.0140.00717.80
8.3.300.0150.00620.93
8.3.290.0130.00820.74
8.3.280.0130.00918.42
8.3.270.0160.00516.70
8.3.260.0110.00616.96
8.3.250.0130.00718.84
8.3.240.0140.00616.68
8.3.230.0150.00516.89
8.3.220.0100.00817.25
8.3.210.0150.00518.59
8.3.200.0040.00616.74
8.3.190.0070.00717.14
8.3.180.0110.01018.91
8.3.170.0140.00616.69
8.3.160.0090.00618.98
8.3.150.0100.01017.16
8.3.140.0070.01020.82
8.3.130.0070.00416.73
8.3.120.0060.00319.05
8.3.110.0060.00320.94
8.3.100.0130.00716.85
8.3.90.0110.00426.77
8.3.80.0080.00316.63
8.3.70.0040.01116.75
8.3.60.0110.00617.00
8.3.50.0160.00921.99
8.3.40.0040.01119.00
8.3.30.0110.00318.94
8.3.20.0000.00820.33
8.3.10.0040.00423.43
8.3.00.0050.00317.63
8.2.300.0120.01018.87
8.2.290.0110.00920.79
8.2.280.0100.00920.42
8.2.270.0130.00716.83
8.2.260.0030.00716.66
8.2.250.0090.00616.74
8.2.240.0050.00517.14
8.2.230.0030.00622.58
8.2.220.0050.00324.06
8.2.210.0110.00726.77
8.2.200.0060.00316.63
8.2.190.0220.00016.58
8.2.180.0090.00925.92
8.2.170.0070.00718.96
8.2.160.0080.00622.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0030.00617.63
8.2.110.0100.00019.27
8.2.100.0090.00317.91
8.2.90.0000.00819.23
8.2.80.0040.00417.97
8.2.70.0060.00317.75
8.2.60.0000.00817.93
8.2.50.0000.00818.07
8.2.40.0030.00619.52
8.2.30.0070.00020.63
8.2.20.0000.00817.69
8.2.10.0000.00918.19
8.2.00.0040.00418.17
8.1.340.0130.00919.69
8.1.330.0090.01023.72
8.1.320.0110.00016.55
8.1.310.0060.00316.26
8.1.300.0090.00918.48
8.1.290.0090.00030.84
8.1.280.0090.00625.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00621.45
8.1.230.0040.00817.70
8.1.220.0050.00317.89
8.1.210.0000.00918.77
8.1.200.0130.00017.38
8.1.190.0040.00417.48
8.1.180.0050.00318.10
8.1.170.0040.00419.17
8.1.160.0000.00822.16
8.1.150.0070.00018.86
8.1.140.0040.00419.64
8.1.130.0020.00517.87
8.1.120.0040.00417.54
8.1.110.0000.00817.50
8.1.100.0000.00817.41
8.1.90.0040.00417.36
8.1.80.0000.00717.40
8.1.70.0040.00417.53
8.1.60.0030.00617.68
8.1.50.0060.00317.64
8.1.40.0090.00017.61
8.1.30.0000.00817.68
8.1.20.0030.00617.61
8.1.10.0000.00817.61
8.1.00.0060.00617.60
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0050.00218.48
8.0.270.0080.00017.43
8.0.260.0080.00017.44
8.0.250.0030.00617.08
8.0.240.0030.00317.08
8.0.230.0000.00717.03
8.0.220.0030.00517.12
8.0.210.0050.00217.12
8.0.200.0000.00717.18
8.0.190.0040.00417.02
8.0.180.0030.00617.16
8.0.170.0060.00317.06
8.0.160.0070.00017.06
8.0.150.0000.00717.08
8.0.140.0070.00016.94
8.0.130.0000.00613.54
8.0.120.0000.00816.95
8.0.110.0040.00417.09
8.0.100.0040.00416.98
8.0.90.0040.00416.96
8.0.80.0060.00917.14
8.0.70.0030.00517.00
8.0.60.0040.00417.08
8.0.50.0040.00417.07
8.0.30.0100.01017.09
8.0.20.0090.01117.42
8.0.10.0000.00817.20
8.0.00.0130.00616.84
7.4.330.0000.00615.10
7.4.320.0030.00316.50
7.4.300.0030.00316.59
7.4.290.0000.00716.55
7.4.280.0070.00016.46
7.4.270.0050.00216.69
7.4.260.0000.00716.63
7.4.250.0000.00816.62
7.4.240.0060.00216.61
7.4.230.0030.00316.74
7.4.220.0110.01116.77
7.4.210.0120.00916.69
7.4.200.0070.00016.32
7.4.160.0090.00916.61
7.4.150.0130.00617.40
7.4.140.0160.01417.86
7.4.130.0120.00916.51
7.4.120.0070.01216.67
7.4.110.0110.00816.48
7.4.100.0160.00916.63
7.4.90.0100.01016.77
7.4.80.0060.01519.39
7.4.70.0090.00916.58
7.4.60.0100.00716.55
7.4.50.0000.00816.45
7.4.40.0050.01416.68
7.4.30.0170.00516.63
7.4.10.0070.01414.97
7.4.00.0090.00915.13
7.3.330.0030.00313.29
7.3.320.0050.00013.26
7.3.310.0080.00016.38
7.3.300.0070.00016.43
7.3.290.0080.01116.44
7.3.280.0090.00916.41
7.3.270.0140.00617.40
7.3.260.0140.00716.71
7.3.250.0130.00516.55
7.3.240.0100.00916.38
7.3.230.0100.01016.39
7.3.210.0120.00816.34
7.3.200.0000.01716.61
7.3.190.0070.00816.77
7.3.180.0090.00916.39
7.3.170.0190.00016.54
7.3.160.0140.00416.29
7.3.130.0040.00814.84
7.3.120.0130.00715.17
7.3.110.0100.01014.75
7.3.100.0040.01115.06
7.3.90.0070.00714.83
7.3.80.0050.00515.23
7.3.70.0090.00915.09
7.3.60.0030.01014.84
7.3.50.0000.01115.08
7.3.40.0070.01014.96
7.3.30.0080.00814.82
7.3.20.0060.00316.85
7.3.10.0090.00616.89
7.3.00.0030.00716.52
7.2.330.0140.00616.88
7.2.320.0120.00716.94
7.2.310.0160.00816.70
7.2.300.0000.02216.69
7.2.290.0120.00716.66
7.2.260.0070.01615.30
7.2.250.0070.01115.34
7.2.240.0060.00915.23
7.2.230.0040.00715.35
7.2.220.0030.01015.15
7.2.210.0040.01114.93
7.2.200.0080.00415.02
7.2.190.0070.01015.14
7.2.180.0090.00314.84
7.2.170.0000.01615.12
7.2.160.0130.00315.26
7.2.150.0030.01216.82
7.2.140.0060.00916.89
7.2.130.0130.00316.70
7.2.120.0030.01516.75
7.2.110.0000.01016.94
7.2.100.0070.01016.54
7.2.90.0070.00716.86
7.2.80.0040.01217.04
7.2.70.0120.00317.00
7.2.60.0030.00716.80
7.2.50.0120.00316.64
7.2.40.0070.00716.65
7.2.30.0030.00916.99
7.2.20.0030.00617.02
7.2.10.0090.00616.84
7.2.00.0040.01116.92
7.1.330.0070.00715.88
7.1.320.0040.00815.90
7.1.310.0040.01115.84
7.1.300.0000.01215.72
7.1.290.0040.01115.94
7.1.280.0030.01015.62
7.1.270.0060.01015.53
7.1.260.0080.00815.54
7.1.250.0060.00915.60
7.1.240.0030.01315.91
7.1.230.0070.00715.62
7.1.220.0030.01015.48
7.1.210.0050.00515.67
7.1.200.0030.01115.92
7.1.190.0060.00315.86
7.1.180.0080.00815.67
7.1.170.0070.00715.66
7.1.160.0060.00615.86
7.1.150.0000.00915.86
7.1.140.0030.01015.80
7.1.130.0070.00315.79
7.1.120.0030.01215.52
7.1.110.0070.00415.70
7.1.100.0050.00716.77
7.1.90.0030.00715.49
7.1.80.0000.01415.64
7.1.70.0020.01016.30
7.1.60.0120.00817.65
7.1.50.0070.00516.41
7.1.40.0000.01716.00
7.1.30.0070.00715.70
7.1.20.0060.00615.77
7.1.10.0090.00615.61
7.1.00.0060.04319.09
7.0.330.0080.00615.40
7.0.320.0030.00615.38
7.0.310.0090.00615.44
7.0.300.0070.00815.34
7.0.290.0030.01015.56
7.0.280.0060.00615.53
7.0.270.0060.00615.27
7.0.260.0030.01215.39
7.0.250.0080.00315.17
7.0.240.0030.01015.35
7.0.230.0040.01115.20
7.0.220.0050.00515.25
7.0.210.0030.01415.52
7.0.200.0070.00314.98
7.0.190.0040.01215.29
7.0.180.0140.00315.44
7.0.170.0120.00415.57
7.0.160.0030.00615.58
7.0.150.0030.00915.46
7.0.140.0070.00715.38
7.0.130.0060.00615.50
7.0.120.0030.01015.31
7.0.110.0040.01115.35
7.0.100.0040.00815.41
7.0.90.0030.01015.26
7.0.80.0040.00815.27
7.0.70.0100.00715.20
7.0.60.0050.02217.59
7.0.50.0030.03516.78
7.0.40.0010.03116.99
7.0.30.0050.03416.71
7.0.20.0120.02216.80
7.0.10.0080.02716.79
7.0.00.0040.05116.68
5.6.400.0030.00714.39
5.6.390.0040.01114.07
5.6.380.0100.00714.34
5.6.370.0110.00414.25
5.6.360.0000.01114.62
5.6.350.0060.00914.57
5.6.340.0070.00714.69
5.6.330.0070.00714.82
5.6.320.0030.00814.64
5.6.310.0050.00514.35
5.6.300.0030.01014.27
5.6.290.0060.01014.53
5.6.280.0030.03517.83
5.6.270.0070.00714.47
5.6.260.0040.01114.57
5.6.250.0030.01014.33
5.6.240.0040.00914.32
5.6.230.0030.00714.59
5.6.220.0080.00414.09
5.6.210.0100.04117.50
5.6.200.0080.04516.49
5.6.190.0040.03717.44
5.6.180.0270.02717.45
5.6.170.0150.03517.32
5.6.160.0050.02717.34
5.6.150.0050.03116.17
5.6.140.0050.03516.37
5.6.130.0080.04316.39
5.6.120.0070.04517.76
5.6.110.0120.04217.68
5.6.100.0030.02817.73
5.6.90.0100.04017.73
5.6.80.0050.04117.44
5.6.70.0030.00714.09
5.6.60.0060.01014.41
5.6.50.0070.00314.27
5.6.40.0030.00914.46
5.6.30.0060.00614.59
5.6.20.0070.00714.35
5.6.10.0030.00914.15
5.6.00.0060.00614.48
5.5.380.0040.00714.46
5.5.370.0060.00914.25
5.5.360.0060.00314.34
5.5.350.0140.02317.41
5.5.340.0120.03716.25
5.5.330.0060.05117.38
5.5.320.0180.04517.33
5.5.310.0230.03717.41
5.5.300.0050.02516.20
5.5.290.0020.02716.12
5.5.280.0070.04517.76
5.5.270.0080.02317.40
5.5.260.0030.02717.62
5.5.250.0050.04317.52
5.5.240.0090.03717.16
5.5.230.0000.01414.33
5.5.220.0070.00714.41
5.5.210.0030.00914.18
5.5.200.0060.00914.14
5.5.190.0030.00714.45
5.5.180.0030.00614.35
5.5.170.0090.00014.06
5.5.160.0030.01014.04
5.5.150.0060.01014.25
5.5.140.0000.01814.37
5.5.130.0000.01814.11
5.5.120.0000.01113.95
5.5.110.0130.00314.39
5.5.100.0030.01414.15
5.5.90.0030.01614.04
5.5.80.0110.00614.34
5.5.70.0080.01014.07
5.5.60.0060.00613.93
5.5.50.0110.00414.06
5.5.40.0110.00814.13
5.5.30.0060.01214.33
5.5.20.0130.00614.32
5.5.10.0100.00714.38
5.5.00.0060.01214.23
5.4.450.0350.03115.32
5.4.440.0300.03215.23
5.4.430.0280.03615.26
5.4.420.0280.03515.38
5.4.410.0280.03015.12
5.4.400.0300.03115.12
5.4.390.0310.02714.94
5.4.380.0330.03515.24
5.4.370.0300.02515.20
5.4.360.0320.03115.01
5.4.350.0370.02715.14
5.4.340.0300.03214.96
5.4.330.0070.00711.41
5.4.320.0280.03215.07
5.4.310.0280.03115.18
5.4.300.0250.03115.02
5.4.290.0290.03215.17
5.4.280.0370.03615.23
5.4.270.0350.03115.11
5.4.260.0310.03615.08
5.4.250.0350.02815.13
5.4.240.0350.02515.03
5.4.230.0300.02715.06
5.4.220.0280.03215.24
5.4.210.0340.02715.13
5.4.200.0350.03515.20
5.4.190.0420.03515.33
5.4.180.0350.04215.08
5.4.170.0250.03515.13
5.4.160.0270.02915.30
5.4.150.0280.03315.23
5.4.140.0310.02713.63
5.4.130.0330.02713.87
5.4.120.0330.03013.85
5.4.110.0300.03113.73
5.4.100.0300.03513.96
5.4.90.0280.02613.91
5.4.80.0280.03013.69
5.4.70.0400.02513.68
5.4.60.0370.03013.81
5.4.50.0350.02814.01
5.4.40.0270.02913.72
5.4.30.0320.02913.95
5.4.20.0360.02513.78
5.4.10.0260.03813.73
5.4.00.0380.03313.46

preferences:
59.55 ms | 3320 KiB | 5 Q