3v4l.org

run code in 300+ PHP versions simultaneously
<?php function profile($c, $n = 1000) { $m = 'microtime'; for ($i = $n * is_callable($c), $t = 0;$i--;$w = $m(1), $c(), $t+= ($m(1) - $w) / $n); return $t; } class Foo { protected $foo; protected $bar; protected $baz; } class FooSelfHydratingProxy extends Foo { /** zero-argument constructor since this is just a helper class for hydration */ public function __construct() { } /** * the `Foo` typehint is not part of the interface - here only for the sake of readability/clearness */ public function hydrate($data, Foo $object) { $object->foo = $data['foo']; $object->bar = $data['bar']; $object->baz = $data['baz']; } /** * the `Foo` typehint is not part of the interface - here only for the sake of readability/clearness */ public function extract(Foo $object) { return array('foo' => $object->foo, 'bar' => $object->bar, 'baz' => $object->baz); } } // data $data = array('foo' => 1, 'bar' => 2, 'baz' => 3); // lastguest function dehydrate($obj){ $class = get_class($obj); $exp = var_export($obj,1); return eval('return '.substr($exp,strpos($exp,'(')+1,-1).';'); } function static_hydrate($class,$dry=null){ static $hydrators = array(); $h = '_Hydrator__'.$class; if (empty($hydrators[$class])) { eval("class $h extends $class { static function __hydrate(\$a) { \$o = new $class(); foreach (\$a as \$n=>\$v) \$o->\$n=\$v; return \$o; } } function hydrate_$class(\$o){return $h::__hydrate(\$o);}" ); $hydrators[$class] = true; } return $dry?$h::__hydrate($dry):new $h; } function hydrate($class,$dry=null){ static $hydrators = array(); $h = '_Hydrator__'.$class; if (empty($hydrators[$class])) { eval("class $h extends $class { static function __hydrate(\$a) { \$o = new $class(); foreach (\$a as \$n=>\$v) \$o->\$n=\$v; return \$o; } } function hydrate_$class(\$o){return $h::__hydrate(\$o);}" ); $hydrators[$class] = true; } return $dry?$h::__hydrate($dry):new $h; } $hydrator = new FooSelfHydratingProxy(); echo 'Ocramius: ',profile(function() use ($data,$hydrator) { $hydrated = new Foo(); $hydrator->hydrate($data, $hydrated); })*1E6,PHP_EOL; $hydr = static_hydrate('Foo'); echo 'Lastguest: ',profile(function() use ($data) { hydrate_Foo($data); })*1E6,PHP_EOL; $hydr = static_hydrate('Foo'); echo 'Lastguest: ',profile(function() use ($data,$hydr) { $hydr->__hydrate($data); })*1E6,PHP_EOL; $foo = hydrate_Foo($data); $foo_s = serialize($foo); echo 'Lastguest: ',profile(function() use ($data,$foo_s) { unserialize($foo_s); })*1E6,PHP_EOL;

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.3.60.0170.00718.39
8.3.50.0120.01022.11
8.3.40.0140.01018.79
8.3.30.0070.01020.29
8.3.20.0060.00320.16
8.3.10.0060.00322.12
8.3.00.0000.00922.43
8.2.180.0190.00316.63
8.2.170.0100.01022.96
8.2.160.0170.00722.12
8.2.150.0030.00624.18
8.2.140.0000.00924.66
8.2.130.0090.01226.16
8.2.120.0060.00617.92
8.2.110.0080.00420.89
8.2.100.0100.00317.78
8.2.90.0030.00717.97
8.2.80.0030.00717.97
8.2.70.0000.01017.63
8.2.60.0000.01017.91
8.2.50.0050.00518.07
8.2.40.0030.00718.34
8.2.30.0030.00618.23
8.2.20.0000.01017.77
8.2.10.0000.01017.79
8.2.00.0000.01417.91
8.1.280.0100.00725.92
8.1.270.0040.00424.66
8.1.260.0060.00326.35
8.1.250.0100.00728.09
8.1.240.0080.00322.52
8.1.230.0030.00920.96
8.1.220.0070.00317.79
8.1.210.0080.00318.83
8.1.200.0040.00817.35
8.1.190.0030.00717.35
8.1.180.0070.00318.10
8.1.170.0070.00318.64
8.1.160.0060.00321.98
8.1.150.0030.00718.70
8.1.140.0060.00317.44
8.1.130.0070.00317.83
8.1.120.0000.00917.39
8.1.110.0030.00717.53
8.1.100.0000.00917.55
8.1.90.0000.01017.39
8.1.80.0050.00517.41
8.1.70.0000.00917.48
8.1.60.0030.00717.64
8.1.50.0080.00317.54
8.1.40.0070.00317.44
8.1.30.0030.00617.64
8.1.20.0040.00717.66
8.1.10.0040.00717.50
8.1.00.0070.00317.61
8.0.300.0000.01120.16
8.0.290.0060.00316.88
8.0.280.0000.00918.42
8.0.270.0060.00317.32
8.0.260.0060.00316.91
8.0.250.0060.00317.11
8.0.240.0030.01017.07
8.0.230.0030.00617.07
8.0.220.0060.00616.90
8.0.210.0030.00616.89
8.0.200.0000.00916.95
8.0.190.0060.00317.06
8.0.180.0030.00916.94
8.0.170.0040.00716.93
8.0.160.0000.01116.89
8.0.150.0060.00316.85
8.0.140.0070.00316.94
8.0.130.0030.00613.39
8.0.120.0000.01116.95
8.0.110.0070.00316.99
8.0.100.0080.00416.98
8.0.90.0030.00716.79
8.0.80.0030.01616.99
8.0.70.0030.00716.89
8.0.60.0030.00717.01
8.0.50.0000.01117.13
8.0.30.0130.01117.01
8.0.20.0120.01117.40
8.0.10.0070.00317.11
8.0.00.0080.01416.75
7.4.330.0000.00715.00
7.4.320.0060.00316.70
7.4.300.0030.00616.62
7.4.290.0040.00716.67
7.4.280.0070.00316.65
7.4.270.0030.00916.51
7.4.260.0030.00716.48
7.4.250.0040.00716.50
7.4.240.0020.00916.51
7.4.230.0030.00616.66
7.4.220.0100.01316.59
7.4.210.0060.01416.55
7.4.200.0070.00316.63
7.4.190.0000.01016.73
7.4.160.0070.01016.46
7.4.150.0160.00617.40
7.4.140.0130.01117.86
7.4.130.0080.01216.48
7.4.120.0080.01216.68
7.4.110.0090.01316.55
7.4.100.0090.01216.71
7.4.90.0090.01216.38
7.4.80.0120.00919.39
7.4.70.0120.00916.55
7.4.60.0120.01816.54
7.4.50.0080.00416.61
7.4.40.0130.00722.77
7.4.30.0100.01016.54
7.4.10.0060.01914.82
7.4.00.0080.01215.03
7.3.330.0030.00613.38
7.3.320.0040.00413.27
7.3.310.0040.00716.34
7.3.300.0060.00316.38
7.3.290.0060.01916.38
7.3.280.0080.01416.43
7.3.270.0090.01217.40
7.3.260.0150.00816.75
7.3.250.0120.00916.61
7.3.240.0080.01416.51
7.3.230.0120.00916.61
7.3.210.0060.01516.62
7.3.200.0100.01019.39
7.3.190.0110.01516.75
7.3.180.0060.01316.48
7.3.170.0090.01216.33
7.3.160.0170.00316.67
7.3.130.0030.01515.08
7.3.120.0090.01414.92
7.3.110.0050.02114.93
7.3.100.0090.01114.96
7.3.90.0050.01315.03
7.3.80.0050.01114.90
7.3.70.0030.01415.05
7.3.60.0110.01114.94
7.3.50.0060.01214.73
7.3.40.0100.01215.01
7.3.30.0070.01214.85
7.3.20.0070.01016.63
7.3.10.0060.01016.71
7.3.00.0100.00816.58
7.2.330.0000.02316.74
7.2.320.0130.00916.69
7.2.310.0070.01416.57
7.2.300.0060.01716.51
7.2.290.0090.01216.77
7.2.260.0070.01415.02
7.2.250.0070.01415.29
7.2.240.0060.01814.93
7.2.230.0050.01515.21
7.2.220.0070.01215.04
7.2.210.0120.00714.98
7.2.200.0030.01715.10
7.2.190.0050.01814.99
7.2.180.0020.01815.14
7.2.170.0050.01814.92
7.2.160.0130.00815.18
7.2.150.0120.00816.93
7.2.140.0070.01216.90
7.2.130.0080.01317.12
7.2.120.0030.01417.05
7.2.110.0060.01316.75
7.2.100.0060.01416.97
7.2.90.0080.00916.85
7.2.80.0040.01617.08
7.2.70.0050.01516.95
7.2.60.0080.01116.87
7.2.50.0050.01416.85
7.2.40.0050.01416.92
7.2.30.0010.01917.07
7.2.20.0060.01516.89
7.2.10.0020.01817.06
7.2.00.0080.01117.77
7.1.330.0110.01215.88
7.1.320.0080.01115.76
7.1.310.0050.01415.79
7.1.300.0080.01115.91
7.1.290.0070.01515.66
7.1.280.0070.01015.67
7.1.270.0070.01215.88
7.1.260.0020.01615.78
7.1.250.0030.01815.80
7.1.240.0070.01715.64
7.1.230.0070.01415.90
7.1.220.0100.01015.82
7.1.210.0100.01315.66
7.1.200.0080.01015.77
7.1.190.0030.01915.80
7.1.180.0080.01115.90
7.1.170.0030.01715.82
7.1.160.0030.02115.79
7.1.150.0100.01315.96
7.1.140.0030.01915.77
7.1.130.0070.01415.86
7.1.120.0060.01315.80
7.1.110.0100.01315.75
7.1.100.0070.01315.71
7.1.90.0130.00716.00
7.1.80.0040.01815.96
7.1.70.0000.01316.56
7.1.60.0050.01216.60
7.1.50.0100.02125.36
7.1.40.0040.01415.81
7.1.30.0040.01115.74
7.1.20.0070.01015.91
7.1.10.0030.01715.95
7.1.00.0070.04319.07
7.0.330.0140.00715.28
7.0.320.0060.02115.57
7.0.310.0100.01015.45
7.0.300.0100.01415.43
7.0.290.0030.01715.35
7.0.280.0030.02215.58
7.0.270.0090.01215.09
7.0.260.0100.00715.21
7.0.250.0040.01215.27
7.0.240.0060.01515.60
7.0.230.0090.01215.37
7.0.220.0040.01415.50
7.0.210.0000.01815.28
7.0.200.0030.01216.20
7.0.190.0040.01415.46
7.0.180.0030.01215.57
7.0.170.0040.01815.43
7.0.160.0090.00915.42
7.0.150.0000.02215.63
7.0.140.0110.04118.76
7.0.130.0000.01915.20
7.0.120.0060.01315.45
7.0.110.0030.01615.46
7.0.100.0070.01415.46
7.0.90.0070.01415.13
7.0.80.0040.01515.22
7.0.70.0070.01015.30
7.0.60.0050.04717.71
7.0.50.0050.04816.67
7.0.40.0020.05816.71
7.0.30.0160.05316.89
7.0.20.0170.04117.00
7.0.10.0030.03116.71
7.0.00.0030.03116.78
5.6.400.0060.01614.10
5.6.390.0090.01614.62
5.6.380.0060.01914.53
5.6.370.0030.02114.67
5.6.360.0030.01914.76
5.6.350.0070.01814.25
5.6.340.0030.02314.23
5.6.330.0030.02414.70
5.6.320.0070.01614.41
5.6.310.0040.01514.56
5.6.300.0140.01014.54
5.6.290.0070.01714.48
5.6.280.0050.04817.88
5.6.270.0140.01014.53
5.6.260.0040.02214.73
5.6.250.0090.01514.56
5.6.240.0000.02314.58
5.6.230.0000.02514.54
5.6.220.0070.02014.55
5.6.210.0080.05517.53
5.6.200.0050.04616.31
5.6.190.0030.05617.64
5.6.180.2270.02817.56
5.6.170.0130.03917.51
5.6.160.0060.04217.75
5.6.150.0030.05616.34
5.6.140.0120.05216.47
5.6.130.0100.03616.51
5.6.120.0050.03617.81
5.6.110.0030.06017.80
5.6.100.0070.04717.64
5.6.90.0030.05217.79
5.6.80.0050.05617.44
5.6.70.0040.02114.64
5.6.60.0060.01814.29
5.6.50.0130.01314.30
5.6.40.0060.01914.39
5.6.30.0000.02514.53
5.6.20.0070.01414.64
5.6.10.0100.01314.45
5.6.00.0070.01514.36
5.5.380.0170.01014.25
5.5.370.0030.02414.48
5.5.360.0030.02114.75
5.5.350.0100.04517.44
5.5.340.0050.04716.27
5.5.330.0070.05317.15
5.5.320.0200.04917.32
5.5.310.0360.03217.47
5.5.300.0020.04216.04
5.5.290.0080.02916.20
5.5.280.0070.04917.55
5.5.270.0030.06217.67
5.5.260.0100.02717.59
5.5.250.0050.05317.37
5.5.240.2080.03217.30
5.5.230.0150.01214.24
5.5.220.0090.01514.34
5.5.210.0060.01814.57
5.5.200.0070.01714.39
5.5.190.0040.01814.29
5.5.180.0030.02114.42
5.5.170.0030.02014.45
5.5.160.0030.01714.14
5.5.150.0030.02614.11
5.5.140.0070.01514.16
5.5.130.0060.01914.42
5.5.120.0030.03114.35
5.5.110.0100.01314.58
5.5.100.0070.02014.53
5.5.90.0060.01314.43
5.5.80.0090.01514.48
5.5.70.0030.02714.23
5.5.60.0070.01413.99
5.5.50.0060.01614.59
5.5.40.0030.02213.97
5.5.30.0070.01714.36
5.5.20.0030.02214.37
5.5.10.0030.02214.36
5.5.00.0060.02114.39
5.4.450.0350.04015.54
5.4.440.0450.03915.30
5.4.430.0210.03915.46
5.4.420.0380.04715.37
5.4.410.0400.03915.41
5.4.400.0080.03815.20
5.4.390.0430.03615.14
5.4.380.0150.03515.02
5.4.370.0050.03614.94
5.4.360.0080.02715.06
5.4.350.0070.03411.69
5.4.340.0050.03211.63
5.4.330.0000.02010.80
5.4.320.0050.03511.84
5.4.310.0060.03411.78
5.4.300.0070.03511.84
5.4.290.0020.03511.89
5.4.280.0050.03511.69
5.4.270.0070.02611.86
5.4.260.0030.03611.76
5.4.250.0050.03011.71
5.4.240.0070.04015.06
5.4.230.0080.03714.91
5.4.220.0120.04215.27
5.4.210.0070.04014.88
5.4.200.0070.03715.09
5.4.190.0060.05415.11
5.4.180.0060.05514.90
5.4.170.0030.04314.85
5.4.160.0050.04315.17
5.4.150.0030.06015.05
5.4.140.0100.05513.88
5.4.130.0080.03613.89
5.4.120.0100.03114.01
5.4.110.0100.03813.87
5.4.100.0070.03813.97
5.4.90.0030.04313.77
5.4.80.0100.03813.91
5.4.70.0130.04614.05
5.4.60.0070.03813.83
5.4.50.0020.04213.82
5.4.40.0050.03813.85
5.4.30.0050.03913.74
5.4.20.0070.03913.96
5.4.10.0080.03913.88
5.4.00.0050.04013.60
5.3.290.0080.02911.82
5.3.280.0090.04112.60
5.3.270.0020.04612.67
5.3.260.0050.04412.75
5.3.250.0080.05012.81
5.3.240.0080.03812.61
5.3.230.0130.03412.60
5.3.220.0020.04612.55
5.3.210.0080.03912.73
5.3.200.0050.04212.58
5.3.190.0120.03212.49
5.3.180.0070.04012.69
5.3.170.0080.05312.65
5.3.160.0000.04712.59
5.3.150.0050.05812.75
5.3.140.0050.03912.57
5.3.130.0070.04612.64
5.3.120.0050.04312.64
5.3.110.0080.03712.73
5.3.100.0050.04112.45
5.3.90.0070.04512.40
5.3.80.0070.05112.38
5.3.70.0080.03812.36
5.3.60.0050.05512.43
5.3.50.0070.04212.38
5.3.40.0080.04812.39
5.3.30.0070.03712.39
5.3.20.0050.04112.20
5.3.10.0070.03911.99
5.3.00.0080.03912.19
5.2.170.0030.05011.26
5.2.160.0030.04311.07
5.2.150.0100.03711.25
5.2.140.0030.06311.35
5.2.130.0030.06011.21
5.2.120.0100.05311.19
5.2.110.0000.05311.20
5.2.100.0000.04311.11
5.2.90.0070.05011.21
5.2.80.0000.04711.33
5.2.70.0000.05311.19
5.2.60.0030.04311.26
5.2.50.0070.03710.89
5.2.40.0000.04311.00
5.2.30.0070.03711.15
5.2.20.0070.03710.90
5.2.10.0070.04011.07
5.2.00.0070.05010.74
5.1.60.0070.03310.28
5.1.50.0070.0439.99
5.1.40.0030.05010.11
5.1.30.0030.03710.45
5.1.20.0030.03710.48
5.1.10.0100.03010.30
5.1.00.0030.04010.26
5.0.50.0070.0238.83
5.0.40.0000.0338.45
5.0.30.0030.0608.26
5.0.20.0070.0308.18
5.0.10.0030.0338.28
5.0.00.0030.0508.25
4.4.90.0030.0206.11
4.4.80.0100.0176.11
4.4.70.0030.0206.11
4.4.60.0070.0176.11
4.4.50.0000.0236.11
4.4.40.0030.0336.11
4.4.30.0000.0306.11
4.4.20.0030.0306.11
4.4.10.0000.0235.94
4.4.00.0000.0336.00
4.3.110.0000.0235.85
4.3.100.0070.0275.82
4.3.90.0070.0305.77
4.3.80.0000.0375.88
4.3.70.0070.0235.82
4.3.60.0000.0235.77
4.3.50.0000.0235.73
4.3.40.0000.0375.71
4.3.30.0000.0304.52
4.3.20.0030.0304.48
4.3.10.0030.0204.47
4.3.00.0070.0307.38

preferences:
67.82 ms | 401 KiB | 5 Q