3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Model { protected $comments; public function __construct() { $this->comments = new class { public function count() { return rand(1, 20); } }; } } class Post extends Model { public function commentCount() { static $cache; return $cache?: $cache = $this->comments->count(); } } $post = new Post(); var_dump($post->commentCount()); var_dump($post->commentCount()); var_dump($post->commentCount()); var_dump($post->commentCount()); var_dump($post->commentCount());

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)
7.4.50.0080.01516.28
7.4.40.0070.01516.41
7.4.30.0160.00316.53
7.4.20.0030.01616.46
7.4.10.0120.01216.60
7.4.00.0110.01116.43
7.3.170.0150.00616.50
7.3.160.0160.00816.25
7.3.150.0110.01116.57
7.3.140.0060.01716.62
7.3.130.0130.01116.24
7.3.120.0130.01016.06
7.3.110.0130.00916.27
7.3.100.0090.00916.39
7.3.90.0150.01216.34
7.3.80.0100.00716.50
7.3.70.0050.01416.25
7.3.60.0160.00316.39
7.3.50.0080.01316.40
7.3.40.0070.01716.46
7.3.30.0060.01316.25
7.3.20.0150.00916.38
7.3.10.0090.01216.39
7.3.00.0070.01116.25
7.2.290.0100.01116.51
7.2.280.0160.00816.65
7.2.270.0100.01416.46
7.2.260.0110.02016.68
7.2.250.0120.01216.75
7.2.240.0100.01016.75
7.2.230.0060.00716.29
7.2.220.0190.00316.62
7.2.210.0080.01116.82
7.2.200.0030.01616.69
7.2.190.0040.00316.54
7.2.180.0120.01116.43
7.2.170.0090.01816.67
7.2.160.0070.01516.55
7.2.150.0160.01016.55
7.2.140.0170.00516.72
7.2.130.0120.01216.60
7.2.120.0090.01216.77
7.2.110.0110.00916.68
7.2.100.0080.01216.63
7.2.90.0130.00916.55
7.2.80.0110.01116.37
7.2.70.0100.01316.37
7.2.60.0060.01416.55
7.2.50.0180.01616.68
7.2.40.0120.00916.55
7.2.30.0190.00416.57
7.2.20.0050.01716.62
7.2.10.0070.01616.66
7.2.00.0080.01216.59

preferences:
31.57 ms | 400 KiB | 5 Q