3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Validator { const GREATER = [self::class, 'greater']; const IS_TYPE = [self::class, 'isType']; public static function all(...$rules) { foreach ($rules as $def) { $rule = array_shift($def); if ($rule(...$def)) { continue; } return false; } return true; } public static function greater($value, $compare) : bool { return $value > $compare; } public static function isType($value, $type) : bool { return gettype($value) === $type; } } class Model { const RULES = [ 'foo' => [ 'integer', // shorthand for [Validator::IS_TYPE, 'integer'] [Validator::GREATER, 10] ] ]; protected $foo; public function set($name, $value) { if ($this->isValid($name, $value)) { $this->$name = $value; return; } throw new Exception("{$name} cannot be {$value}"); } function isValid() : bool { $rules = []; foreach (self::RULES[$name] as $rule) { // convenience: turn strings into typehints if (is_string($rule)) { $rules[] = [Validator::IS_TYPE, $value]; continue; } // ... other convenience parsing ... // for fully defined rules, just add value arg at proper spot array_splice($rule, 1, 0, $value); $rules[] = $rule; } return Validator::ALL($rules); } } $m = new Model; $m->set('foo', 15); var_dump($m); $m->set('foo', 7);

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.0160.00318.43
8.3.50.0180.00316.26
8.3.40.0120.00318.70
8.3.30.0070.00718.86
8.3.20.0080.00020.00
8.3.10.0040.00421.55
8.3.00.0000.00820.95
8.2.180.0110.01118.41
8.2.170.0140.00722.96
8.2.160.0100.00722.08
8.2.150.0040.00424.18
8.2.140.0040.01124.66
8.2.130.0000.00922.18
8.2.120.0070.00726.35
8.2.110.0150.00320.88
8.2.100.0080.00417.84
8.2.90.0060.00319.22
8.2.80.0000.00819.36
8.2.70.0000.00817.75
8.2.60.0040.00418.03
8.2.50.0040.00418.10
8.2.40.0040.00420.39
8.2.30.0040.00419.24
8.2.20.0070.00018.28
8.2.10.0040.00418.02
8.2.00.0050.00218.14
8.1.280.0040.01125.92
8.1.270.0040.00422.10
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.81
8.1.230.0080.00317.83
8.1.220.0040.00417.76
8.1.210.0050.00318.77
8.1.200.0030.00617.47
8.1.190.0000.00817.23
8.1.180.0000.00818.10
8.1.170.0030.00618.47
8.1.160.0040.00418.91
8.1.150.0040.00418.96
8.1.140.0000.00819.60
8.1.130.0000.00718.89
8.1.120.0080.00017.39
8.1.110.0070.00417.48
8.1.100.0040.00417.39
8.1.90.0050.00317.37
8.1.80.0040.00417.46
8.1.70.0000.00817.50
8.1.60.0040.00417.65
8.1.50.0000.00917.54
8.1.40.0040.00417.43
8.1.30.0000.00817.60
8.1.20.0040.00417.57
8.1.10.0080.00017.58
8.1.00.0080.00417.38
8.0.300.0070.00018.77
8.0.290.0050.00216.75
8.0.280.0000.00818.52
8.0.270.0030.00317.20
8.0.260.0000.00616.96
8.0.250.0030.00316.98
8.0.240.0050.00516.98
8.0.230.0060.00317.04
8.0.220.0030.00316.86
8.0.210.0080.00016.93
8.0.200.0000.00717.03
8.0.190.0040.00417.03
8.0.180.0000.00716.93
8.0.170.0040.00417.03
8.0.160.0000.00716.96
8.0.150.0030.00916.94
8.0.140.0030.00516.95
8.0.130.0030.00313.43
8.0.120.0000.00716.85
8.0.110.0000.00716.88
8.0.100.0060.00316.81
8.0.90.0040.00417.03
8.0.80.0100.00616.93
8.0.70.0000.00717.04
8.0.60.0040.00416.86
8.0.50.0000.00716.94
8.0.30.0080.00917.12
8.0.20.0120.00917.40
8.0.10.0050.00217.12
8.0.00.0130.01017.01
7.4.330.0030.00315.55
7.4.320.0030.00316.63
7.4.300.0080.00016.53
7.4.290.0030.00316.52
7.4.280.0050.00316.67
7.4.270.0000.00816.59
7.4.260.0060.00013.29
7.4.250.0060.00316.46
7.4.240.0080.00016.66
7.4.230.0070.00016.50
7.4.220.0090.00916.59
7.4.210.0090.00616.72
7.4.200.0070.00016.62
7.4.160.0080.01016.51
7.4.150.0180.00617.40
7.4.140.0110.01117.86
7.4.130.0100.01016.62
7.4.120.0080.01016.57
7.4.110.0160.00616.46
7.4.100.0060.01216.52
7.4.90.0110.00716.66
7.4.80.0130.01019.39
7.4.70.0060.01016.35
7.4.60.0030.01316.54
7.4.50.0100.00316.75
7.4.40.0060.01016.59
7.4.30.0140.00716.53
7.4.00.0070.01015.00
7.3.330.0060.00013.51
7.3.320.0060.00013.23
7.3.310.0070.00016.33
7.3.300.0030.00316.48
7.3.290.0090.00916.42
7.3.280.0100.00616.44
7.3.270.0090.01417.40
7.3.260.0090.01216.65
7.3.250.0100.00916.44
7.3.240.0090.01016.47
7.3.230.0100.01316.45
7.3.210.0070.01616.45
7.3.200.0090.00916.67
7.3.190.0160.00016.44
7.3.180.0070.01016.72
7.3.170.0100.00616.48
7.3.160.0130.01016.47
7.3.10.0030.00816.27
7.3.00.0000.01116.18
7.2.330.0070.01716.70
7.2.320.0120.00616.70
7.2.310.0060.01216.86
7.2.300.0000.01816.38
7.2.290.0130.00416.75
7.2.130.0120.00916.22
7.2.120.0090.01316.61
7.2.110.0000.01116.63
7.2.100.0060.00916.54
7.2.90.0040.00816.28
7.2.80.0060.00916.39
7.2.70.0120.00316.72
7.2.60.0100.00716.73
7.2.50.0120.00316.72
7.2.40.0030.01216.59
7.2.30.0080.00816.29
7.2.20.0120.00316.42
7.2.10.0060.00915.93
7.2.00.0000.01516.80
7.1.250.0060.00815.49
7.1.200.0030.00615.63
7.1.70.0030.00617.22
7.1.60.0900.01733.27
7.1.50.0930.01732.66
7.1.40.0170.01332.61
7.1.30.0900.00732.67
7.1.20.0700.01032.60
7.1.10.0200.01014.63
7.1.00.0500.01014.54
7.0.200.0800.01014.87
7.0.190.1200.00715.06
7.0.180.0600.01314.36
7.0.170.0030.01314.38
7.0.160.0500.01314.32
7.0.150.0100.01014.48
7.0.140.0470.01014.46
7.0.130.0600.01014.65
7.0.120.0670.01014.73
7.0.110.0430.01714.73
7.0.100.0500.01014.59
7.0.90.0630.00714.56
7.0.80.0530.00714.50
7.0.70.0800.01314.68
7.0.60.0900.01014.41
7.0.50.0670.01014.47
7.0.40.0530.01314.57
7.0.30.0670.00714.64
7.0.20.0500.01014.79
7.0.10.0700.00714.70
7.0.00.0500.00714.76

preferences:
53.91 ms | 400 KiB | 5 Q