3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo{ class Bar { public static function testClass(): \Closure { return function(){}; } } function testFunc(): \Closure { return function(){}; } $closureFromGlobalScope = function(){}; } namespace { $closures = [ 'Anonymous function created in a class' => Foo\Bar::testClass(), 'Anonymous function created in a function' => Foo\testFunc(), 'Anonymous function created in a global scope' => $closureFromGlobalScope, 'First class callable of a static method' => Foo\Bar::testClass(...), 'First class callable of a function' => Foo\testFunc(...), ]; foreach ($closures as $name => $closure) { $reflection = new ReflectionFunction($closure); echo <<<EOS {$name}: getName {$reflection->getName()} getNamespaceName {$reflection->getNamespaceName()} getClosureScopeClass {$reflection->getClosureScopeClass()?->getName()} EOS, "\n\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)
8.4.120.0140.00719.01
8.4.110.0110.00920.53
8.4.100.0110.01017.85
8.4.90.0100.00820.55
8.4.80.0130.00720.64
8.4.70.0090.00719.06
8.4.60.0130.00820.38
8.4.50.0080.01220.25
8.4.40.0130.00718.92
8.4.30.0160.00324.10
8.4.20.0140.00719.45
8.4.10.0000.00919.43
8.3.250.0100.00618.55
8.3.240.0090.00816.43
8.3.230.0140.00616.89
8.3.220.0110.00920.67
8.3.210.0040.00416.52
8.3.200.0130.00816.64
8.3.190.0110.00717.01
8.3.180.0050.00318.95
8.3.170.0150.00017.32
8.3.160.0070.01120.82
8.3.150.0000.00819.10
8.3.140.0110.00418.29
8.3.130.0080.00016.59
8.3.120.0360.00616.68
8.3.110.0320.00616.22
8.3.100.0290.00616.54
8.3.90.0220.00016.54
8.3.80.0290.00416.45
8.3.70.0240.01016.55
8.3.60.0250.00016.29
8.3.50.0170.00516.21
8.3.40.0190.00317.50
8.3.30.0150.01517.30
8.3.20.0300.00717.47
8.3.10.0130.00417.63
8.3.00.0130.00517.13
8.2.290.0090.00917.07
8.2.280.0050.00618.45
8.2.270.0040.00816.46
8.2.260.0040.00417.12
8.2.250.0140.00718.58
8.2.240.0300.00916.43
8.2.230.0300.00916.31
8.2.220.0210.01416.24
8.2.210.0240.01516.25
8.2.200.0330.00716.44
8.2.190.0400.00016.36
8.2.180.0250.01316.50
8.2.170.0340.00817.51
8.2.160.0340.00717.43
8.2.150.0310.01017.47
8.2.140.0350.00717.30
8.2.130.0360.01017.31
8.2.120.0360.00317.61
8.2.110.0270.01217.35
8.2.100.0340.00717.56
8.2.90.0310.00917.71
8.2.80.0280.00617.71
8.2.70.0290.00317.32
8.2.60.0370.00417.20
8.2.50.0300.01117.40
8.2.40.0400.01017.34
8.2.30.0320.01117.48
8.2.20.0340.00317.29
8.2.10.0340.01217.39
8.2.00.0290.01017.25
8.1.330.0130.00616.16
8.1.320.0090.00616.22
8.1.310.0100.00718.44
8.1.300.0280.01116.23
8.1.290.0300.01016.15
8.1.280.0370.00315.80
8.1.270.0350.00417.32
8.1.260.0330.01317.11
8.1.250.0290.00717.37
8.1.240.0060.01117.14
8.1.230.0290.00617.07
8.1.220.0270.00317.21
8.1.210.0150.00317.19
8.1.200.0210.01517.21
8.1.190.0320.00616.95
8.1.180.0260.01217.22
8.1.170.0350.00317.29
8.1.160.0290.00917.01
8.1.150.0300.00717.16
8.1.140.0310.00616.98
8.1.130.0120.00917.30
8.1.120.0210.01017.07
8.1.110.0170.01417.04
8.1.100.0240.00916.91
8.1.90.0330.00717.33
8.1.80.0330.01217.29
8.1.70.0400.00017.27
8.1.60.0320.01017.16
8.1.50.0350.00517.23
8.1.40.0280.01217.31
8.1.30.0370.00417.53
8.1.20.0300.00817.34
8.1.10.0310.00917.47
8.1.00.0200.02017.27

preferences:
44.32 ms | 403 KiB | 5 Q