3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a; protected $b; public $c; } class FooCountable implements \Countable { private $elements = [1,2,3]; public function count() { return count($this->elements); } } $tests = [ 'array' => [1,2,3], 'string' => 'hello world', 'number' => 123, 'iterator' => new \ArrayIterator([1,2,3]), 'countable' => new \FooCountable(), 'zero' => 0, 'string_zero' => '0', 'object' => new \Foo(), 'stdClass' => new \stdClass, 'null' => null, 'empty' => '', 'boolt' => true, 'boolf' => false ]; if (!\function_exists('is_countable')) { function is_countable($value) { echo 'used shim '; return \is_array($value) || $value instanceof \Countable; } } function countValid($array_or_countable, $mode = \COUNT_NORMAL) { if (\is_countable($array_or_countable)) { return \count($array_or_countable, $mode); } return null === $array_or_countable ? 0 : 1; } foreach($tests as $key => $test) { echo $key . ': ' . print_r(countValid($test), 1) . \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)
8.3.60.0140.00718.68
8.3.50.0070.01118.09
8.3.40.0040.01118.87
8.3.30.0040.01118.55
8.3.20.0050.00318.81
8.3.10.0080.00019.18
8.3.00.0080.00023.52
8.2.180.0080.00818.41
8.2.170.0140.00022.96
8.2.160.0100.00322.25
8.2.150.0110.00324.18
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0040.00419.48
8.2.110.0100.00022.20
8.2.100.0100.00017.91
8.2.90.0080.00017.97
8.2.80.0040.00419.34
8.2.70.0050.00317.75
8.2.60.0060.00317.63
8.2.50.0040.00418.10
8.2.40.0000.00918.28
8.2.30.0040.00418.05
8.2.20.0030.00718.07
8.2.10.0000.00718.11
8.2.00.0050.00318.27
8.1.280.0110.00425.92
8.1.270.0060.00322.07
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0080.00020.88
8.1.230.0060.00620.85
8.1.220.0000.00817.78
8.1.210.0030.00518.77
8.1.200.0080.00017.23
8.1.190.0050.00317.23
8.1.180.0000.00818.10
8.1.170.0060.00320.45
8.1.160.0040.00418.87
8.1.150.0070.00018.90
8.1.140.0000.00718.78
8.1.130.0030.00320.15
8.1.120.0040.00417.41
8.1.110.0030.00517.39
8.1.100.0000.00717.36
8.1.90.0000.00817.32
8.1.80.0040.00417.44
8.1.70.0040.00417.36
8.1.60.0080.00417.59
8.1.50.0060.00317.56
8.1.40.0040.00417.53
8.1.30.0030.00517.60
8.1.20.0000.00817.56
8.1.10.0030.00517.55
8.1.00.0030.00617.41
8.0.300.0040.00419.95
8.0.290.0040.00416.75
8.0.280.0000.00718.47
8.0.270.0000.00716.71
8.0.260.0060.00018.48
8.0.250.0070.00316.84
8.0.240.0080.00016.87
8.0.230.0030.00316.84
8.0.220.0060.00316.80
8.0.210.0030.00316.88
8.0.200.0000.00616.83
8.0.190.0040.00416.94
8.0.180.0030.00516.82
8.0.170.0030.00616.96
8.0.160.0040.00817.00
8.0.150.0000.00716.80
8.0.140.0000.00816.93
8.0.130.0030.00313.33
8.0.120.0000.00716.82
8.0.110.0000.00716.93
8.0.100.0080.00016.95
8.0.90.0070.00016.74
8.0.80.0050.01216.93
8.0.70.0040.00416.74
8.0.60.0040.00416.94
8.0.50.0000.00716.76
8.0.30.0120.00717.03
8.0.20.0110.01017.40
8.0.10.0030.00516.98
8.0.00.0070.01216.76
7.4.330.0030.00315.55
7.4.320.0000.00616.43
7.4.300.0060.00016.50
7.4.290.0040.00416.51
7.4.280.0050.00316.51
7.4.270.0030.00516.59
7.4.260.0000.00816.52
7.4.250.0000.00716.51
7.4.240.0070.00016.63
7.4.230.0040.00416.70
7.4.220.0000.00716.70
7.4.210.0080.01016.64
7.4.200.0000.00716.43
7.4.160.0100.00716.50
7.4.140.0090.01017.86
7.4.130.0050.01316.51
7.4.120.0100.00616.48
7.4.110.0060.01216.48
7.4.100.0100.00716.58
7.4.90.0140.00716.55
7.4.80.0130.01019.39
7.4.70.0080.01116.54
7.4.60.0040.01416.48
7.4.50.0060.00616.41
7.4.40.0070.01116.43
7.4.10.0090.00916.64
7.4.00.0090.00815.81
7.3.330.0000.00513.38
7.3.320.0000.00513.32
7.3.310.0030.00316.32
7.3.300.0030.00316.42
7.3.290.0030.00316.42
7.3.280.0040.01116.33
7.3.260.0120.01016.52
7.3.240.0110.00616.55
7.3.230.0140.00716.60
7.3.210.0090.00916.58
7.3.200.0030.01216.59
7.3.190.0060.00916.27
7.3.180.0030.01616.36
7.3.170.0080.01216.55
7.3.160.0100.00716.71
7.3.130.0060.01116.40
7.3.120.0040.01516.44
7.3.110.0060.01216.43
7.3.100.0060.00916.50
7.3.90.0070.01016.55
7.3.80.0030.01616.36
7.3.70.0100.00715.27
7.3.60.0070.01315.33
7.3.50.0100.00815.41
7.3.40.0090.00315.31
7.3.30.0090.00515.21
7.3.20.0830.00716.58
7.3.10.0820.00516.58
7.3.00.0710.01016.45
7.2.330.0170.00316.88
7.2.320.0120.01316.52
7.2.310.0150.00616.51
7.2.300.0040.01316.69
7.2.290.0120.00916.66
7.2.260.0100.01016.71
7.2.250.0040.01516.61
7.2.240.0120.00316.77
7.2.230.0070.01316.59
7.2.220.0060.01316.62
7.2.210.0030.00916.78
7.2.200.0040.01415.51
7.2.190.0080.00915.56
7.2.180.0070.01715.65
7.2.170.0070.01115.50
7.2.160.0080.00915.55
7.2.150.0750.00616.73
7.2.140.0740.01016.92
7.2.130.0620.00716.77
7.2.120.0790.00716.33
7.2.110.0590.01216.37
7.2.100.1050.00816.10
7.2.90.1030.00616.11
7.2.80.0760.01016.16
7.2.70.0950.00816.19
7.2.60.0780.00816.26
7.2.50.1070.00916.27
7.2.40.1160.00716.34
7.2.30.0840.00916.17
7.2.20.1080.00916.10
7.2.10.0830.00716.15
7.2.00.1020.00716.12
7.1.330.0060.00917.36
7.1.320.0110.00617.28
7.1.310.0070.01017.46
7.1.300.0110.00616.32
7.1.290.0070.00716.29
7.1.280.0090.01016.35
7.1.270.0080.00916.31
7.1.260.0050.00816.21
7.1.250.0740.00815.67
7.1.240.0760.01015.31
7.1.230.0810.01015.31
7.1.220.1500.01015.05
7.1.210.1000.00915.14
7.1.200.0870.00715.20
7.1.190.0840.00715.12
7.1.180.1000.00815.16
7.1.170.1100.00615.16
7.1.160.1310.00615.06
7.1.150.1130.00915.13
7.1.140.0970.00715.10
7.1.130.1150.01115.17
7.1.120.1300.01015.11
7.1.110.0970.01215.09
7.1.100.1160.01015.09
7.1.90.1140.01015.03
7.1.80.1150.00815.17
7.1.70.1050.00815.18
7.1.60.1280.01018.08
7.1.50.1820.01118.04
7.1.40.1670.00818.15
7.1.30.2010.00818.06
7.1.20.1970.01118.02
7.1.10.1600.00614.98
7.1.00.1250.00715.04
7.0.330.0970.00514.68
5.6.400.0170.00714.36
5.6.390.0150.01114.48
5.6.380.0140.01014.32

preferences:
39.15 ms | 400 KiB | 5 Q