3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MemoryCache { protected $data = []; public function set($key, $value) { $this->data[$key] = $value; } public function get($key) { return $this->data[$key] ?? NULL; } } class InternalReferenceCycleVoodooMemoryCacheWrapper { protected $memoryCache; protected $cycle; public function __construct(MemoryCache $memoryCache) { $this->memoryCache = $memoryCache; $this->cycle = $this; } public function unwrap() { return $this->memoryCache; } } class GarbageCollectableMemoryCacheDecorator { protected $memoryCacheWrapperWeakref; protected function createWrapper(): InternalReferenceCycleVoodooMemoryCacheWrapper { return new InternalReferenceCycleVoodooMemoryCacheWrapper(new MemoryCache()); } protected function initWeakref(): WeakReference { return $this->memoryCacheWrapperWeakref = WeakReference::create($this->createWrapper()); } protected function getMemoryCache() { $weakref = $this->memoryCacheWrapperWeakref ?? $this->initWeakref(); $wrapper = $weakref->get() ?? $this->initWeakref()->get(); return $wrapper->unwrap(); } public function set($key, $value) { $this->getMemoryCache()->set($key, $value); } public function get($key) { return $this->getMemoryCache()->get($key); } } $mc = new GarbageCollectableMemoryCacheDecorator(); $mc->set('foo', 'bar'); printf("Data value after set: %s\n", print_r($mc->get('foo'), 1)); gc_collect_cycles(); printf("Data value after GC: %s\n", print_r($mc->get('foo'), 1)); $mc->set('foo', 'baz'); printf("Data value after set: %s\n", print_r($mc->get('foo'), 1)); gc_collect_cycles(); printf("Data value after GC: %s\n", print_r($mc->get('foo'), 1));

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.30.0060.01019.52
8.5.20.0100.01019.59
8.5.10.0100.00916.86
8.5.00.0120.01020.11
8.4.180.0110.01219.84
8.4.170.0120.00824.00
8.4.160.0170.00523.95
8.4.150.0080.00516.96
8.4.140.0110.01117.84
8.4.130.0150.00617.95
8.4.120.0050.00420.72
8.4.110.0120.00918.93
8.4.100.0080.00417.82
8.4.90.0090.01217.71
8.4.80.0130.00817.89
8.4.70.0060.00617.72
8.4.60.0110.01018.51
8.4.50.0120.01018.75
8.4.40.0100.01019.46
8.4.30.0160.00320.49
8.4.20.0070.01418.75
8.4.10.0100.01018.57
8.3.300.0130.00620.93
8.3.290.0130.00918.48
8.3.280.0070.00516.23
8.3.270.0100.01016.48
8.3.260.0130.00616.58
8.3.250.0110.00519.00
8.3.240.0110.00816.61
8.3.230.0130.00716.41
8.3.220.0060.01117.12
8.3.210.0080.00716.54
8.3.200.0060.00316.77
8.3.190.0140.00417.10
8.3.180.0070.01117.02
8.3.170.0070.01120.67
8.3.160.0040.01118.41
8.3.150.0120.00617.13
8.3.140.0110.00718.36
8.3.130.0000.00818.52
8.3.120.0030.00720.65
8.3.110.0090.00016.72
8.3.100.0000.00916.63
8.3.90.0090.00626.77
8.3.80.0100.00016.88
8.3.70.0150.00016.63
8.3.60.0070.00716.63
8.3.50.0070.01118.27
8.3.40.0110.00421.05
8.3.30.0080.00818.64
8.3.20.0080.00024.18
8.3.10.0030.00524.66
8.3.00.0040.00426.16
8.2.300.0110.01017.94
8.2.290.0060.00220.63
8.2.280.0130.00618.47
8.2.270.0090.00917.20
8.2.260.0100.00716.90
8.2.250.0040.01416.57
8.2.240.0060.00317.09
8.2.230.0080.00020.94
8.2.220.0040.00424.06
8.2.210.0150.00326.77
8.2.200.0040.00416.88
8.2.190.0120.00616.63
8.2.180.0090.00625.92
8.2.170.0090.01219.08
8.2.160.0150.00322.96
8.2.150.0050.00325.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00019.48
8.2.110.0000.00922.27
8.2.100.0090.00318.03
8.2.90.0050.00319.05
8.2.80.0040.00417.97
8.2.70.0000.00817.50
8.2.60.0040.00417.92
8.2.50.0030.01018.05
8.2.40.0060.00318.22
8.2.30.0040.00418.12
8.2.20.0000.00718.07
8.2.10.0050.00321.10
8.2.00.0040.00419.28
8.1.340.0080.01318.42
8.1.330.0110.00416.66
8.1.320.0170.00916.25
8.1.310.0110.00716.12
8.1.300.0040.00416.43
8.1.290.0060.00930.84
8.1.280.0090.00625.92
8.1.270.0070.00023.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00423.92
8.1.230.0040.00817.60
8.1.220.0000.00817.74
8.1.210.0040.00419.01
8.1.200.0060.00317.36
8.1.190.0030.00517.36
8.1.180.0030.00518.10
8.1.170.0050.00318.70
8.1.160.0040.00418.90
8.1.150.0040.00418.74
8.1.140.0040.00419.12
8.1.130.0030.00320.15
8.1.120.0040.00417.49
8.1.110.0040.00417.38
8.1.100.0000.00717.43
8.1.90.0050.00217.38
8.1.80.0100.00017.44
8.1.70.0000.00717.49
8.1.60.0080.00017.49
8.1.50.0020.00517.53
8.1.40.0050.00317.61
8.1.30.0040.00417.81
8.1.20.0060.00317.61
8.1.10.0040.00417.61
8.1.00.0070.00317.46
8.0.300.0030.00518.77
8.0.290.0080.00016.58
8.0.280.0030.00318.51
8.0.270.0030.00317.99
8.0.260.0000.00718.64
8.0.250.0070.00017.00
8.0.240.0070.00016.97
8.0.230.0040.00417.06
8.0.220.0040.00416.99
8.0.210.0000.00716.83
8.0.200.0000.00817.04
8.0.190.0040.00417.04
8.0.180.0000.00716.97
8.0.170.0070.00316.91
8.0.160.0040.00417.00
8.0.150.0030.00316.85
8.0.140.0030.00616.85
8.0.130.0030.00313.36
8.0.120.0040.00416.82
8.0.110.0000.00716.96
8.0.100.0040.00416.87
8.0.90.0040.00417.03
8.0.80.0060.01016.95
8.0.70.0250.00516.87
8.0.60.0190.00816.90
8.0.50.0150.01516.86
8.0.30.0220.00916.90
8.0.20.0240.00716.91
8.0.10.0170.01417.14
8.0.00.0100.00717.05
7.4.330.0050.00015.55
7.4.320.0030.00316.65
7.4.300.0040.00416.58
7.4.290.0000.00816.61
7.4.280.0050.00216.69
7.4.270.0000.00716.70
7.4.260.0000.00513.35
7.4.250.0000.00716.54
7.4.240.0000.00716.71
7.4.230.0050.00316.71
7.4.220.0070.00016.74
7.4.210.0210.01016.60
7.4.200.0230.00316.64
7.4.190.0210.00816.77
7.4.180.0260.00716.62
7.4.160.0160.01016.60
7.4.150.0240.00316.68
7.4.140.0180.00916.50
7.4.130.0240.00916.40
7.4.120.0210.01116.49
7.4.110.0170.01416.50
7.4.100.0150.01116.70
7.4.90.0140.01416.41
7.4.80.0210.00316.49
7.4.70.0170.01116.62
7.4.60.0170.01116.62
7.4.50.0150.01116.63
7.4.40.0070.01816.36
7.4.30.0290.00016.64
7.4.20.0150.01216.45
7.4.10.0130.01316.60
7.4.00.0190.00616.61
7.3.330.0030.00316.21
7.3.320.0030.00313.18
7.3.310.0030.00316.48
7.3.300.0000.00716.25
7.3.290.0450.00316.39
7.3.280.0230.00716.35
7.3.270.0120.01216.42
7.3.260.0130.01316.48
7.3.250.0160.01316.42
7.3.240.0170.00916.42
7.3.230.0180.00816.46
7.3.220.0150.01216.38
7.3.210.0260.00416.35
7.3.200.0170.00716.32
7.3.190.0230.00816.47
7.3.180.0240.00316.39
7.3.170.0140.01116.35
7.3.160.0190.00816.42
7.3.150.0210.01216.35
7.3.140.0190.00816.43
7.3.130.0220.00716.41
7.3.120.0250.00916.27
7.3.110.0320.00516.35
7.3.100.0220.00816.27
7.3.90.0070.01716.57
7.3.80.0170.00916.27
7.3.70.0190.01116.41
7.3.60.0190.01216.40
7.3.50.0200.00516.48
7.3.40.0130.01616.47
7.3.30.0170.00816.43
7.3.20.0120.01316.50
7.3.10.0190.00716.43
7.3.00.0210.01116.47

preferences:
56.62 ms | 1421 KiB | 5 Q