3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class StringObject { protected string $string; public function __tostring(): string { return $this->string; } } class StringObjectException extends Exception {} class CountableString extends StringObject { private int $lettersCount; public function __construct(string $string) { $this->string = $string; $this->lettersCount = mb_strlen($string); } public function countLetters(): int { return $this->lettersCount; } } class EmptyStringException extends Exception {}; class NotEmptyString extends StringObject { public function __construct(string $string) { if ('' === $string) { throw new EmptyStringException('Expected not empty string.'); } $this->string = $string; } } class TooLongStringException extends Exception {}; class TenLettersString extends StringObject { private const MAX_LETTERS_COUNT = 10; public function __construct(CountableString $string) { if (self::MAX_LETTERS_COUNT < $string->countLetters()) { throw new TooLongStringException( sprintf('Expected string not longer then: "%d letters" got: "%s"', self::MAX_LETTERS_COUNT, $string ) ); } $this->string = $string; } } $countableString = new CountableString('Тестовая строка'); $notEmptyString = new NotEmptyString($countableString); echo $countableString->countLetters() . PHP_EOL; echo $countableString . PHP_EOL; $tenLetterLongString = new TenLettersString($countableString);

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.4.120.0120.00824.15
8.4.110.0120.00920.58
8.4.100.0130.00718.91
8.4.90.0130.00620.65
8.4.80.0060.00318.08
8.4.70.0040.00418.22
8.4.60.0090.01218.75
8.4.50.0130.00820.49
8.4.40.0060.00318.01
8.4.30.0120.00318.86
8.4.20.0070.01018.15
8.4.10.0160.00419.53
8.3.250.0140.00518.89
8.3.240.0110.00817.25
8.3.230.0120.00416.91
8.3.220.0120.00518.88
8.3.210.0120.00416.98
8.3.200.0110.00816.74
8.3.190.0070.00816.98
8.3.180.0090.01016.84
8.3.170.0120.00618.69
8.3.160.0100.01020.48
8.3.150.0170.00318.74
8.3.140.0070.01116.76
8.3.130.0170.00318.48
8.3.120.0000.00819.05
8.3.110.0000.00920.94
8.3.100.0060.00924.06
8.3.90.0030.01026.77
8.3.80.0000.01017.97
8.3.70.0130.01018.55
8.3.60.0150.00418.41
8.3.50.0130.00617.06
8.3.40.0070.00720.17
8.3.30.0120.00621.82
8.3.20.0080.00024.18
8.3.10.0080.00024.66
8.3.00.0030.00621.87
8.2.290.0110.00820.61
8.2.280.0030.00518.77
8.2.270.0040.01417.50
8.2.260.0070.00718.27
8.2.250.0140.00316.95
8.2.240.0040.00417.08
8.2.230.0080.00022.58
8.2.220.0060.00337.54
8.2.210.0040.00426.77
8.2.200.0000.00918.42
8.2.190.0090.00618.54
8.2.180.0140.00416.88
8.2.170.0120.00319.13
8.2.160.0080.00522.96
8.2.150.0040.00425.66
8.2.140.0000.00924.66
8.2.130.0060.00319.38
8.2.120.0060.00318.90
8.2.110.0060.00318.75
8.2.100.0030.00618.69
8.2.90.0030.00618.82
8.2.80.0000.00918.77
8.2.70.0040.00418.91
8.2.60.0060.00318.76
8.2.50.0030.00618.90
8.2.40.0060.00318.91
8.2.30.0040.00418.64
8.2.20.0030.00618.64
8.2.10.0040.00418.67
8.2.00.0060.00318.58
8.1.330.0130.00722.02
8.1.320.0110.01016.54
8.1.310.0050.00318.63
8.1.300.0070.01016.52
8.1.290.0060.00330.84
8.1.280.0100.00725.92
8.1.270.0080.00023.99
8.1.260.0090.00018.75
8.1.250.0060.00318.45
8.1.240.0090.00018.64
8.1.230.0080.00018.43
8.1.220.0060.00318.48
8.1.210.0030.00618.42
8.1.200.0000.00918.58
8.1.190.0060.00318.45
8.1.180.0050.00318.63
8.1.170.0060.00318.57
8.1.160.0090.00018.61
8.1.150.0090.00018.70
8.1.140.0060.00318.49
8.1.130.0060.00318.57
8.1.120.0060.00318.58
8.1.110.0090.00018.71
8.1.100.0040.00418.41
8.1.90.0040.00418.61
8.1.80.0080.00018.68
8.1.70.0080.00018.45
8.1.60.0090.00018.92
8.1.50.0060.00318.83
8.1.40.0000.00818.79
8.1.30.0000.00918.99
8.1.20.0030.00619.04
8.1.10.0050.00518.75
8.1.00.0060.00318.79
8.0.300.0050.00318.06
8.0.290.0030.00518.15
8.0.280.0030.00518.08
8.0.270.0080.00018.15
8.0.260.0060.00317.95
8.0.250.0060.00318.01
8.0.240.0060.00318.21
8.0.230.0000.01018.20
8.0.220.0060.00318.11
8.0.210.0090.00018.10
8.0.200.0040.00418.10
8.0.190.0090.00017.83
8.0.180.0030.00718.14
8.0.170.0060.00318.13
8.0.160.0100.00017.92
8.0.150.0090.00017.98
8.0.140.0070.00417.94
8.0.130.0090.00018.12
8.0.120.0040.00417.83
8.0.110.0040.00418.16
8.0.100.0040.00418.00
8.0.90.0090.00018.13
8.0.80.0070.00318.13
8.0.70.0050.00318.13
8.0.60.0050.00318.04
8.0.50.0060.00318.15
8.0.30.0080.00018.20
8.0.20.0060.00318.05
8.0.10.0050.00319.95

preferences:
27.24 ms | 403 KiB | 5 Q