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 ]; function countValid($array_or_countable, $mode = \COUNT_NORMAL) { if ( (\PHP_VERSION_ID >= 70300 && \is_countable($array_or_countable)) || \is_array($array_or_countable) || $array_or_countable instanceof \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; } echo 'undefined: ' . print_r(countValid($undefined), 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.0040.01518.80
8.3.50.0170.00318.17
8.3.40.0000.01518.83
8.3.30.0070.00718.84
8.3.20.0030.00518.73
8.3.10.0000.00819.23
8.3.00.0050.00323.48
8.2.180.0140.00325.92
8.2.170.0130.00318.91
8.2.160.0030.01022.10
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0070.00020.93
8.2.110.0090.00021.05
8.2.100.0060.00618.03
8.2.90.0080.00017.91
8.2.80.0000.00918.20
8.2.70.0000.00817.63
8.2.60.0040.00418.22
8.2.50.0060.00318.07
8.2.40.0040.00419.66
8.2.30.0040.00417.84
8.2.20.0050.00318.07
8.2.10.0060.00318.14
8.2.00.0100.00018.31
8.1.280.0040.01225.92
8.1.270.0030.00622.02
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0090.00022.61
8.1.230.0090.00320.97
8.1.220.0090.00017.74
8.1.210.0050.00318.78
8.1.200.0060.00317.35
8.1.190.0000.00917.35
8.1.180.0040.00418.10
8.1.170.0000.00818.92
8.1.160.0040.00419.00
8.1.150.0050.00218.57
8.1.140.0040.00419.02
8.1.130.0000.00717.39
8.1.120.0040.00717.39
8.1.110.0040.00417.46
8.1.100.0040.00417.44
8.1.90.0070.00017.38
8.1.80.0050.00317.48
8.1.70.0070.00417.37
8.1.60.0060.00617.61
8.1.50.0000.00817.56
8.1.40.0000.00817.54
8.1.30.0040.00417.73
8.1.20.0000.00917.63
8.1.10.0030.00517.50
8.1.00.0040.00417.42
8.0.300.0040.00419.97
8.0.290.0060.00316.75
8.0.280.0000.00718.46
8.0.270.0030.00316.82
8.0.260.0000.00816.91
8.0.250.0000.00717.04
8.0.240.0030.00317.00
8.0.230.0030.00317.05
8.0.220.0080.00316.96
8.0.210.0000.00716.96
8.0.200.0000.00817.06
8.0.190.0080.00017.03
8.0.180.0050.00316.93
8.0.170.0060.00317.01
8.0.160.0030.00716.93
8.0.150.0030.00516.84
8.0.140.0000.00716.82
8.0.130.0070.00013.46
8.0.120.0040.00417.00
8.0.110.0030.00516.93
8.0.100.0050.00316.93
8.0.90.0040.00416.93
8.0.80.0100.00916.92
8.0.70.0000.00816.98
8.0.60.0000.00717.01
8.0.50.0040.00416.98
8.0.30.0120.00617.14
8.0.20.0130.01517.32
8.0.10.0170.00717.14
8.0.00.0120.00716.91
7.4.330.0050.00015.55
7.4.320.0030.00316.40
7.4.300.0030.00316.63
7.4.290.0000.00716.67
7.4.280.0000.00716.53
7.4.270.0000.00716.54
7.4.260.0070.00016.60
7.4.250.0030.00316.47
7.4.240.0040.00416.55
7.4.230.0040.00416.74
7.4.220.0050.00316.58
7.4.210.0080.00816.67
7.4.200.0030.00316.27
7.4.160.0100.00916.64
7.4.150.0110.01416.49
7.4.140.0080.01117.60
7.4.130.0120.00716.58
7.4.120.0100.00816.61
7.4.110.0070.01016.54
7.4.100.0110.00616.54
7.4.90.0080.01216.53
7.4.80.0150.00817.89
7.4.70.0090.01316.42
7.4.60.0140.00616.46
7.4.50.0120.00316.46
7.4.40.0130.01016.53
7.4.30.0170.00616.41
7.4.20.0180.00016.52
7.4.10.0080.00915.51
7.4.00.0100.00815.36
7.3.330.0030.00313.30
7.3.320.0000.00513.40
7.3.310.0030.00316.44
7.3.300.0000.00816.45
7.3.290.0040.00416.39
7.3.280.0060.00916.45
7.3.270.0180.00916.41
7.3.260.0100.01016.51
7.3.250.0170.01116.22
7.3.240.0070.01016.52
7.3.230.0140.00516.54
7.3.220.0000.01816.40
7.3.210.0060.01316.48
7.3.200.0120.00616.63
7.3.190.0080.00916.48
7.3.180.0140.00716.50
7.3.170.0110.00916.43
7.3.160.0120.00916.52
7.3.150.0140.00716.42
7.3.140.0070.01416.53
7.3.130.0100.00915.46
7.3.120.0110.00715.36
7.3.110.0120.00615.42
7.3.100.0090.01015.01
7.3.90.0100.00815.07
7.3.80.0110.00715.02
7.3.70.0100.00715.03
7.3.60.0090.00715.18
7.3.50.0090.00715.02
7.3.40.0090.01015.05
7.3.30.0080.00914.95
7.3.20.0460.00915.66
7.3.10.0290.00515.77
7.3.00.0300.00715.78
7.2.340.0260.00516.81
7.2.330.0170.01016.71
7.2.320.0180.00816.70
7.2.310.0160.00916.64
7.2.300.0180.00716.75
7.2.290.0170.01016.81
7.2.280.0270.00716.79
7.2.270.0210.01116.51
7.2.260.0160.00815.58
7.2.250.0140.00715.47
7.2.240.0120.01115.47
7.2.230.0100.00915.33
7.2.220.0100.00815.34
7.2.210.0120.00715.53
7.2.200.0070.01115.22
7.2.190.0100.00915.30
7.2.180.0070.01215.37
7.2.170.0090.01015.25
7.2.160.0090.00715.16
7.2.150.0390.00716.05
7.2.140.0290.01015.97
7.2.130.0280.00916.12
7.2.120.0330.00715.98
7.2.110.0410.00715.98
7.2.100.0910.01015.87
7.2.90.0720.00915.87
7.2.80.0830.00715.81
7.2.70.0690.00715.91
7.2.60.0720.00715.91
7.2.50.0710.00915.86
7.2.40.1020.00715.83
7.2.30.0820.00815.88
7.2.20.0780.00815.85
7.2.10.0860.00815.88
7.2.00.0840.00815.83
7.1.330.0330.00715.72
7.1.320.0130.00714.98
7.1.310.0090.00715.07
7.1.300.0100.00614.69
7.1.290.0070.01014.81
7.1.280.0100.00714.94
7.1.270.0100.00914.98
7.1.260.0100.00814.80
7.1.250.0420.00814.98
7.1.240.0410.01114.66
7.1.230.0360.00814.75
7.1.220.1070.01014.63
7.1.210.0900.01014.64
7.1.200.0900.00914.53
7.1.190.0980.00914.54
7.1.180.0880.00814.70
7.1.170.0860.00914.61
7.1.160.0900.00614.55
7.1.150.0740.00814.65
7.1.140.0960.00814.57
7.1.130.0960.00914.63
7.1.120.0960.00614.57
7.1.110.0800.01014.69
7.1.100.0940.00814.61
7.1.90.0800.00814.63
7.1.80.0750.00914.67
7.1.70.0830.00814.62
7.1.60.0710.01116.44
7.1.50.1020.00916.41
7.1.40.1140.00516.41
7.1.30.1310.00716.42
7.1.20.1410.01316.45
7.1.10.1060.00814.59
7.1.00.0620.00914.54
7.0.330.0500.00914.02
7.0.320.0130.00713.91
7.0.310.0270.00914.04
7.0.300.0670.00814.09
7.0.290.0490.01013.98
7.0.280.0320.01113.90
7.0.270.0510.01413.83
7.0.260.0340.00913.90
7.0.250.0400.00613.98
7.0.240.0320.00714.03
7.0.230.0260.01014.08
7.0.220.0240.00513.96
7.0.210.0230.01114.05
7.0.200.0190.00813.98
7.0.190.0300.00514.08
7.0.180.0210.00713.91
7.0.170.0230.00613.96
7.0.160.0270.00814.10
7.0.150.0240.01113.95
7.0.140.0390.00814.11
7.0.130.0250.00813.96
7.0.120.0140.00614.07
7.0.110.0230.00914.03
7.0.100.0230.01414.00
7.0.90.0280.00613.92
7.0.80.0240.00814.02
7.0.70.0180.00613.95
7.0.60.0270.00713.93
7.0.50.0260.00614.12
7.0.40.0200.00914.01
7.0.30.0250.00513.97
7.0.20.0220.00713.85
7.0.10.0450.00914.03
7.0.00.0190.00913.94
5.6.400.0130.00814.57
5.6.390.0130.00714.60
5.6.380.0130.00814.42
5.6.370.0100.01014.63
5.6.360.0130.01014.83
5.6.350.0170.00814.71
5.6.340.0120.01114.81
5.6.330.0160.00814.79
5.6.320.0130.00914.62
5.6.310.0120.01014.80
5.6.300.0130.01114.78
5.6.290.0160.00714.53
5.6.280.0140.00914.73
5.6.270.0140.00714.71
5.6.260.0150.00714.71
5.6.250.0150.01114.69
5.6.240.0190.00614.78
5.6.230.0140.01014.77
5.6.220.0140.00814.74
5.6.210.0140.00914.69
5.6.200.0120.00914.92
5.6.190.0130.01014.75
5.6.180.0160.00614.65
5.6.170.0140.01214.71
5.6.160.0170.00614.71
5.6.150.0150.00814.75
5.6.140.0120.01214.73
5.6.130.0170.00914.55
5.6.120.0140.00814.80
5.6.110.0130.00814.66
5.6.100.0130.00914.67
5.6.90.0130.00814.79
5.6.80.0080.01214.56
5.6.70.0140.00814.64
5.6.60.0130.00814.59
5.6.50.0160.00814.67
5.6.40.0120.01114.61
5.6.30.0120.01114.56
5.6.20.0140.01014.55
5.6.10.0150.00614.60
5.6.00.0120.01114.66
5.5.380.0150.00814.12
5.5.370.0150.00714.09
5.5.360.0120.00813.99
5.5.350.0130.00714.08
5.5.340.0090.01214.10
5.5.330.0110.01114.07
5.5.320.0150.00714.11
5.5.310.0140.00814.08
5.5.300.0090.01214.14
5.5.290.0130.00814.11
5.5.280.0120.00814.13
5.5.270.0140.00514.20
5.5.260.0150.00714.06
5.5.250.0150.00514.02
5.5.240.0130.00714.07
5.5.230.0110.00914.04
5.5.220.0150.00714.07
5.5.210.0130.00914.00
5.5.200.0150.00814.12
5.5.190.0150.00613.88
5.5.180.0140.00914.08
5.5.170.0160.00614.41
5.5.160.0130.00814.06
5.5.150.0140.00914.10
5.5.140.0130.00614.02
5.5.130.0120.00914.15
5.5.120.0130.00714.06
5.5.110.0110.01113.99
5.5.100.0140.00914.03
5.5.90.0170.00613.98
5.5.80.0100.00914.01
5.5.70.0120.01014.11
5.5.60.0150.00813.96
5.5.50.0150.01014.13
5.5.40.0130.00713.95
5.5.30.0140.00814.09
5.5.20.0130.00713.99
5.5.10.0140.00713.93
5.5.00.0140.00813.98
5.4.450.0100.00611.76
5.4.440.0100.00511.71
5.4.430.0100.00711.68
5.4.420.0110.00411.79
5.4.410.0080.00711.77
5.4.400.0110.00511.73
5.4.390.0100.00611.57
5.4.380.0130.00411.67
5.4.370.0090.00811.64
5.4.360.0120.00611.59
5.4.350.0110.00511.58
5.4.340.0140.00311.64
5.4.330.0100.00611.45
5.4.320.0120.00511.72
5.4.310.0090.00811.71
5.4.300.0090.00811.70
5.4.290.0090.00511.73
5.4.280.0120.00511.62
5.4.270.0120.00611.73
5.4.260.0170.00111.65
5.4.250.0110.00611.43
5.4.240.0110.00511.78
5.4.230.0110.00711.65
5.4.220.0120.00711.71
5.4.210.0080.01111.61
5.4.200.0110.00611.67
5.4.190.0130.00511.57
5.4.180.0110.00811.59
5.4.170.0110.00811.59
5.4.160.0100.00811.58
5.4.150.0120.00611.53
5.4.140.0060.01111.61
5.4.130.0110.00811.77
5.4.120.0130.00611.73
5.4.110.0090.00811.71
5.4.100.0130.00411.62
5.4.90.0120.00511.70
5.4.80.0080.00911.68
5.4.70.0100.00811.67
5.4.60.0110.00511.67
5.4.50.0130.00611.65
5.4.40.0080.00911.63
5.4.30.0130.00411.63
5.4.20.0090.00911.65
5.4.10.0120.00811.71
5.4.00.0120.00511.73
5.3.290.0090.00711.34
5.3.280.0120.00511.29
5.3.270.0060.01211.35
5.3.260.0130.00411.29
5.3.250.0130.00511.32
5.3.240.0120.00611.31
5.3.230.0130.00511.23
5.3.220.0120.00411.24
5.3.210.0120.00411.26
5.3.200.0120.00411.31
5.3.190.0110.00611.28
5.3.180.0110.00611.41
5.3.170.0090.00811.43
5.3.160.0120.00511.41
5.3.150.0080.00911.40
5.3.140.0110.00511.36
5.3.130.0100.00611.32
5.3.120.0100.00711.33
5.3.110.0110.00511.33
5.3.100.0100.00811.37
5.3.90.0100.00511.41
5.3.80.0070.01011.35
5.3.70.0080.00611.32
5.3.60.0090.00611.31
5.3.50.0090.00711.31
5.3.40.0090.00711.33
5.3.30.0110.00511.26
5.3.20.0090.00811.28
5.3.10.0090.00611.16
5.3.00.0080.00711.21
5.2.170.0070.00410.87
5.2.160.0070.00510.78
5.2.150.0080.00510.84
5.2.140.0110.00410.80
5.2.130.0060.00610.81
5.2.120.0070.00510.79
5.2.110.0070.00510.79
5.2.100.0070.00710.82
5.2.90.0090.00410.80
5.2.80.0080.00710.79
5.2.70.0090.00510.73
5.2.60.0090.00410.78
5.2.50.0070.00710.83
5.2.40.0080.00710.79
5.2.30.0080.00710.69
5.2.20.0080.00510.69
5.2.10.0060.00710.60
5.2.00.0050.00810.63
5.1.60.0090.00210.46
5.1.50.0070.00510.46
5.1.40.0060.00610.46
5.1.30.0080.00510.46
5.1.20.0070.00510.46
5.1.10.0070.00410.46
5.1.00.0070.00610.46
5.0.50.0080.00310.46
5.0.40.0060.00410.46
5.0.30.0050.00510.46
5.0.20.0060.00410.46
5.0.10.0090.00110.46
5.0.00.0060.00510.46
4.4.90.0050.00310.46
4.4.80.0060.00210.46
4.4.70.0060.00310.46
4.4.60.0050.00210.46
4.4.50.0050.00310.46
4.4.40.0040.00410.46
4.4.30.0050.00410.46
4.4.20.0040.00410.46
4.4.10.0060.00210.46
4.4.00.0060.00210.46
4.3.110.0040.00310.46
4.3.100.0050.00310.46
4.3.90.0040.00410.46
4.3.80.0060.00110.46
4.3.70.0060.00210.46
4.3.60.0040.00310.46
4.3.50.0030.00410.46
4.3.40.0050.00210.46
4.3.30.0070.00110.46
4.3.20.0050.00210.46
4.3.10.0040.00310.46
4.3.00.0020.00410.46

preferences:
62.52 ms | 401 KiB | 5 Q