3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a{ function __construct(){ echo 'class a __construct'."\n"; } function a1(){ echo 'a1'."\n"; } function a2(){ echo 'a2'."\n"; } function a3(){ echo 'a3'."\n"; } } class b{ protected $cache; function __construct(){ echo 'class b __construct'."\n"; } function b1($tags='tags'){ return new a(); } function b2($tags='tags'){ static $cache=[]; if(isset($cache[$tags])) return $cache[$tags]; return $cache[$tags]=new a(); } function b3($tags='tags'){ if(isset($this->cache[$tags])) return $this->cache[$tags]; return $this->cache[$tags]=new a(); } } /*内存计算*/ $start = memory_get_usage(); $b=new b(); $b->b1()->a1(); $b->b1()->a2(); $b->b1()->a3(); /*内存计算*/ $end = memory_get_usage(); echo '内存'.($end-$start)."\n"; /*内存计算*/ $start = memory_get_usage(); $b=new b(); $b->b2()->a1(); $b->b2()->a2(); $b->b2()->a3(); /*内存计算*/ $end = memory_get_usage(); echo '内存'.($end-$start)."\n"; /*内存计算*/ $start = memory_get_usage(); $b=new b(); $b->b3()->a1(); $b->b3()->a2(); $b->b3()->a3(); /*内存计算*/ $end = memory_get_usage(); echo '内存'.($end-$start)."\n";

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.3.40.0060.00614.85
7.3.30.0130.00014.66
7.3.20.0100.00316.51
7.3.10.0050.00816.34
7.3.00.0030.01516.62
7.2.170.0060.00914.91
7.2.160.0070.00715.21
7.2.150.0110.00417.04
7.2.140.0080.00416.70
7.2.130.0060.00617.02
7.2.120.0110.00016.92
7.2.110.0050.00617.09
7.2.100.0110.01117.05
7.2.90.0080.00416.72
7.2.80.0110.00016.95
7.2.70.0030.00917.06
7.2.60.0060.00616.87
7.2.50.0030.01016.92
7.2.40.0130.01016.85
7.2.30.0080.00517.02
7.2.20.0040.00716.92
7.2.10.0060.01516.91
7.2.00.0030.00916.68
7.1.280.0050.00815.95
7.1.270.0070.00615.50
7.1.260.0070.00315.53
7.1.250.0100.00315.98

preferences:
29.57 ms | 400 KiB | 5 Q