3v4l.org

run code in 500+ PHP versions simultaneously
<?php function countUniqueCharacters(string $str): int { static $cache = []; if (key_exists($str, $cache)) { return $cache[$str]; } echo PHP_EOL . "*** doing the work ***"; return $cache[$str] = count( array_filter( count_chars($str, 1), fn($count) => $count === 1 ) ); } $tests = ['one', 'two', 'three', 'one', 'two']; foreach ($tests as $test) { echo PHP_EOL . "$test : " . countUniqueCharacters($test); }

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.70.0120.00718.63
8.5.60.0120.00716.86
8.5.50.0110.00716.59
8.5.30.0080.00921.24
8.5.20.0130.00519.48
8.5.10.0080.00920.25
8.5.00.0120.00920.18
8.4.210.0130.00919.68
8.4.180.0090.01322.14
8.4.170.0110.01120.43
8.4.160.0100.01122.18
8.4.150.0090.00316.86
8.4.140.0150.00617.52
8.4.130.0100.00317.53
8.4.120.0150.00424.20
8.4.110.0080.01317.97
8.4.100.0100.01118.73
8.4.90.0030.00518.93
8.4.80.0120.00518.66
8.4.70.0110.00417.81
8.4.60.0090.01018.83
8.4.50.0140.00718.64
8.4.40.0140.00719.76
8.4.30.0090.00918.87
8.4.20.0040.00419.57
8.4.10.0000.01022.04
8.3.300.0130.00820.70
8.3.290.0100.01120.71
8.3.280.0120.00718.36
8.3.270.0150.00516.53
8.3.260.0110.00616.66
8.3.250.0110.00818.96
8.3.240.0070.00918.88
8.3.230.0100.01016.55
8.3.220.0140.00518.80
8.3.210.0150.00516.66
8.3.200.0040.00416.82
8.3.190.0060.00217.29
8.3.180.0060.00416.98
8.3.170.0130.00620.60
8.3.160.0150.00316.55
8.3.150.0180.00017.07
8.3.140.0040.00416.66
8.3.130.0080.00018.51
8.3.120.0000.01019.11
8.3.110.0080.00016.38
8.3.100.0060.00324.06
8.3.90.0040.00426.77
8.3.80.0040.00416.63
8.3.70.0070.00716.58
8.3.60.0070.01316.63
8.3.50.0090.00620.08
8.3.40.0060.01220.09
8.3.30.0090.00918.72
8.3.20.0070.00024.18
8.3.10.0000.00824.66
8.3.00.0080.00026.16
8.2.300.0100.00922.09
8.2.290.0120.00720.32
8.2.280.0110.00818.21
8.2.270.0120.00617.25
8.2.260.0110.00718.09
8.2.250.0070.00718.20
8.2.240.0090.00019.05
8.2.230.0050.00320.94
8.2.220.0060.00337.54
8.2.210.0110.00426.77
8.2.200.0080.00016.75
8.2.190.0180.00317.00
8.2.180.0000.01525.92
8.2.170.0090.01219.04
8.2.160.0140.00022.96
8.2.150.0070.00025.66
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00419.63
8.2.110.0040.00422.21
8.2.100.0030.00919.45
8.2.90.0080.00017.75
8.2.80.0080.00018.91
8.2.70.0040.00417.38
8.2.60.0040.00417.93
8.2.50.0050.00318.07
8.2.40.0040.00419.88
8.2.30.0040.00418.06
8.2.20.0000.00720.57
8.2.10.0020.00518.14
8.2.00.0000.00719.31
8.1.340.0140.00817.63
8.1.330.0120.00722.04
8.1.320.0120.00718.45
8.1.310.0070.01117.72
8.1.300.0000.00818.30
8.1.290.0030.00918.88
8.1.280.0070.00725.92
8.1.270.0040.00422.01
8.1.260.0090.00026.35
8.1.250.0000.00728.09
8.1.240.0070.01120.43
8.1.230.0000.01217.59
8.1.220.0060.00317.74
8.1.210.0080.00018.77
8.1.200.0060.00317.48
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0040.00418.50
8.1.160.0030.00518.90
8.1.150.0080.00018.55
8.1.140.0040.00417.46
8.1.130.0070.00019.23
8.1.120.0050.00517.41
8.1.110.0060.00817.35
8.1.100.0100.00417.48
8.1.90.0140.00117.40
8.1.80.0070.01017.43
8.1.70.0110.00417.36
8.1.60.0120.00417.52
8.1.50.0160.00017.49
8.1.40.0150.00017.54
8.1.30.0110.00317.53
8.1.20.0080.00417.51
8.1.10.0100.00517.43
8.1.00.0100.00717.37
8.0.300.0000.00818.77
8.0.290.0000.00816.75
8.0.280.0030.00318.36
8.0.270.0000.00717.31
8.0.260.0080.00016.82
8.0.250.0120.00316.89
8.0.240.0040.01116.93
8.0.230.0050.01116.77
8.0.220.0120.00516.92
8.0.210.0100.00616.81
8.0.200.0170.00016.84
8.0.190.0170.00016.91
8.0.180.0110.00716.87
8.0.170.0090.00716.87
8.0.160.0140.00316.73
8.0.150.0160.00016.76
8.0.140.0070.01116.86
8.0.130.0090.00716.80
8.0.120.0120.00616.86
8.0.110.0150.00416.76
8.0.100.0130.00316.87
8.0.90.0170.00016.82
8.0.80.0150.00316.85
8.0.70.0110.00616.77
8.0.60.0030.01016.71
8.0.50.0170.00016.85
8.0.30.0090.00916.77
8.0.20.0060.00616.80
8.0.10.0040.00916.96
7.4.330.0000.00515.55
7.4.320.0000.00916.41
7.4.300.0120.00316.45
7.4.290.0100.00516.45
7.4.280.0050.00516.41
7.4.270.0040.00716.59
7.4.260.0040.00416.42
7.4.250.0100.00316.56
7.4.240.0100.00316.50
7.4.230.0170.00016.43
7.4.220.0150.00016.49
7.4.210.0100.00416.61
7.4.200.0120.00316.48
7.4.190.0090.00616.66
7.4.180.0110.00416.64
7.4.160.0110.00316.59
7.4.150.0090.00516.34
7.4.140.0090.00516.39
7.4.130.0120.00316.45
7.4.120.0090.00616.45
7.4.110.0060.00616.31
7.4.100.0040.00916.57
7.4.90.0120.00216.33
7.4.80.0110.00316.48
7.4.70.0080.00616.46
7.4.60.0070.00716.32
7.4.50.0070.00716.23
7.4.40.0060.00616.24
7.4.30.0080.00416.43
7.4.20.0060.00616.43
7.4.10.0080.00816.48
7.4.00.0120.00316.42

preferences:
64.62 ms | 1271 KiB | 5 Q