3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Node { public $color; public $key; public $value; public $left; public $right; public function __construct($key, $value, $color) { $this->key = $key; $this->value = $value; $this->color = $color; } public function compare($key) { if ($this->key < $key) return -1; elseif ($this->key > $key) return 1; else return 0; } } class RBTree { const RED = true; const BLACK = false; private $root; public function isEmpty() { return $this->root == null; } public function put($key, $value) { $this->root = $this->insert($this->root, (int)$key, $value); $this->root->color = self::BLACK; } public function get($key) { $x = $this->search($this->root, (int)$key); return $x ? $x->value : null; } private function isRed($h) { return $h ? $h->color : false; } private function insert($x, $key, $value) { if (!$x) return new Node($key, $value, self::RED); $cmp = $x->compare($key); if ($cmp > 0) $x->right = insert($x->right, $key, $value); elseif ($cmp < 0) $x->left = insert($x->left, $key, $value); else $x->value = $value; if ($this->isRed($x->right) && !$this->isRed($x->left)) $x = $this->rotateLeft($x); if ($this->isRed($x->left) && $this->isRed($x->left->left)) $x = $this->rotateRight($x); if ($this->isRed($x->left) && $this->isRed($x->right)) $this->flipColors($x); return $x; } private function search($x, $key) { while ($x) { $cmp = $x->compare($key); if ($cmp > 0) $x = $x->right; elseif ($cmp < 0) $x = $x->left; else return $x; } return null; } private function flipColors($h) { $h->color = !$h.color; $h->left->color = !$h->left->color; $h->right->color = $h->right->color; } private function rotateLeft($h) { $x = $h->right; $h->right = $x->left; $x->left = $h; $x->color = $x->left->color; $x->left->color = self::RED; return $x; } private function rotateRight($h) { $x = $h->left; $h->left = $x->right; $x->right = $h; $x->color = $x->right->color; $x->right->color = self::RED; return $x; } }

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.0100.01016.63
8.3.50.0090.00518.10
8.3.40.0150.00318.52
8.3.30.0070.00718.72
8.3.20.0080.00818.59
8.3.10.0000.00820.36
8.3.00.0120.00319.13
8.2.180.0160.00616.38
8.2.170.0080.01122.96
8.2.160.0040.01218.66
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0070.00718.72
8.2.110.0070.00320.54
8.2.100.0030.01319.39
8.2.90.0040.00419.11
8.2.80.0000.00817.97
8.2.70.0080.00017.50
8.2.60.0040.00417.80
8.2.50.0040.00418.10
8.2.40.0000.00720.61
8.2.30.0020.00519.23
8.2.20.0040.00417.61
8.2.10.0060.00317.59
8.2.00.0040.00417.48
8.1.280.0120.00325.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0030.00628.09
8.1.240.0090.00023.93
8.1.230.0110.00017.64
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0000.00817.23
8.1.190.0080.00317.13
8.1.180.0000.00818.10
8.1.170.0040.00418.39
8.1.160.0000.00718.69
8.1.150.0040.00418.79
8.1.140.0000.00717.33
8.1.130.0000.00717.69
8.1.120.0000.00717.39
8.1.110.0000.00717.35
8.1.100.0000.00717.27
8.1.90.0000.00717.38
8.1.80.0040.00417.27
8.1.70.0000.00717.36
8.1.60.0020.00517.39
8.1.50.0040.00417.30
8.1.40.0030.00517.50
8.1.30.0000.00817.46
8.1.20.0000.00817.47
8.1.10.0050.00317.45
8.1.00.0040.00417.22
8.0.300.0040.00419.95
8.0.290.0080.00016.63
8.0.280.0000.00718.30
8.0.270.0000.00817.19
8.0.260.0000.00716.66
8.0.250.0000.00716.88
8.0.240.0000.00716.78
8.0.230.0030.00316.85
8.0.220.0030.00316.83
8.0.210.0030.00316.79
8.0.200.0070.00016.89
8.0.190.0000.00716.87
8.0.180.0040.00416.83
8.0.170.0060.00316.74
8.0.160.0040.00416.92
8.0.150.0030.00516.78
8.0.140.0030.00516.80
8.0.130.0000.00513.22
8.0.120.0070.00016.81
8.0.110.0050.00316.75
8.0.100.0020.00516.71
8.0.90.0000.00716.66
8.0.80.0120.00316.75
8.0.70.0050.00316.66
8.0.60.0040.00416.75
8.0.50.0040.00416.76
8.0.30.0110.00616.72
8.0.20.0080.01016.92
8.0.10.0070.00016.93
8.0.00.0090.01116.63
7.4.330.0020.00212.90
7.4.320.0060.00016.45
7.4.300.0060.00016.56
7.4.290.0040.00416.51
7.4.280.0000.00716.52
7.4.270.0000.00716.44
7.4.260.0000.00613.12
7.4.250.0050.00316.50
7.4.240.0000.00716.43
7.4.230.0030.00316.61
7.4.220.0090.00916.53
7.4.210.0100.00316.61
7.4.200.0030.00316.32
7.4.190.0050.00216.56
7.4.160.0080.00816.30
7.4.150.0060.01216.32
7.4.140.0120.00616.56
7.4.130.0080.01116.61
7.4.120.0050.01116.42
7.4.110.0130.00316.38
7.4.100.0070.01016.55
7.4.90.0130.00616.41
7.4.80.0030.01319.39
7.4.70.0140.00416.30
7.4.60.0030.01616.41
7.4.50.0040.00416.57
7.4.40.0130.00316.47
7.4.30.0140.00816.50
7.4.00.0120.00314.89
7.3.330.0030.00313.20
7.3.320.0050.00013.06
7.3.310.0030.00316.25
7.3.300.0070.00016.19
7.3.290.0070.00716.21
7.3.280.0100.00816.30
7.3.270.0160.00916.26
7.3.260.0090.01416.48
7.3.250.0060.01416.24
7.3.240.0100.00716.48
7.3.230.0100.00716.34
7.3.210.0090.02216.39
7.3.200.0100.01316.48
7.3.190.0060.01316.30
7.3.180.0160.00016.45
7.3.170.0050.01416.47
7.3.160.0090.00616.35
7.3.120.0090.00614.66
7.2.330.0110.00716.34
7.2.320.0110.00716.55
7.2.310.0090.01316.50
7.2.300.0130.01216.26
7.2.290.0030.01416.46
7.2.00.0030.01319.29
7.1.100.0040.00717.71
7.1.70.0050.00516.81
7.1.60.0100.01319.31
7.1.50.0070.01416.85
7.1.00.0000.07722.26
7.0.200.0670.00314.61
7.0.140.0030.07721.95
7.0.120.0070.06022.14
7.0.60.0130.05019.91
7.0.50.0100.04717.89
7.0.40.0130.08020.27
7.0.30.0200.04720.09
7.0.20.0270.07320.13
7.0.10.0030.04720.38
7.0.00.0000.06720.16
5.6.280.0000.07720.95
5.6.210.0070.03720.79
5.6.200.0130.07718.14
5.6.190.0130.03320.34
5.6.180.0500.07320.48
5.6.170.0200.04320.56
5.6.160.0030.05320.50
5.6.150.0100.08018.30
5.6.140.0100.07718.18
5.6.130.0200.07318.14
5.6.120.0170.07021.03
5.6.110.0170.07320.99
5.6.100.0300.05321.00
5.6.90.0070.05320.99
5.6.80.0070.08020.54
5.5.350.0000.08320.46
5.5.340.0070.08017.96
5.5.330.0030.05320.47
5.5.320.0200.05020.38
5.5.310.0270.04020.23
5.5.300.0100.05018.07
5.5.290.0030.05017.99
5.5.280.0030.04021.01
5.5.270.0170.07720.99
5.5.260.0070.06320.89
5.5.250.0030.04020.49
5.5.240.0200.08020.29
5.4.450.0000.07019.57
5.4.440.0030.05319.47
5.4.430.0100.05319.40
5.4.420.0070.06319.58
5.4.410.0030.08319.02
5.4.400.0070.04718.98
5.4.390.0100.04719.24
5.4.380.0070.04319.15
5.4.370.0000.06319.00
5.4.360.0100.07719.08
5.4.350.0100.05319.23
5.4.340.0030.04319.15
5.4.320.0170.06718.85
5.4.310.0070.04319.24
5.4.300.0030.04319.07
5.4.290.0030.06318.97
5.4.280.0070.07019.20
5.4.270.0070.08319.17
5.4.260.0130.04718.87
5.4.250.0000.07018.84
5.4.240.0000.04019.23
5.4.230.0100.03718.99
5.4.220.0100.04719.13
5.4.210.0030.08019.20
5.4.200.0030.08018.86
5.4.190.0070.07318.84
5.4.180.0130.05019.23
5.4.170.0000.05019.00
5.4.160.0030.07019.12
5.4.150.0030.06018.90
5.4.140.0100.06016.55
5.4.130.0100.03016.55
5.4.120.0030.04316.46
5.4.110.0030.04016.49
5.4.100.0130.07016.42
5.4.90.0070.04316.52
5.4.80.0000.07716.46
5.4.70.0070.03716.57
5.4.60.0000.05316.38
5.4.50.0000.04716.27
5.4.40.0030.04016.41
5.4.30.0070.07016.44
5.4.20.0030.07316.44
5.4.10.0100.06716.41
5.4.00.0030.05315.87
5.3.290.0130.06314.74
5.3.280.0070.07714.65
5.3.270.0070.07314.66
5.3.260.0030.05314.65
5.3.250.0030.06714.65
5.3.240.0070.03714.64
5.3.230.0100.05714.67
5.3.220.0030.03714.68
5.3.210.0130.03014.76
5.3.200.0070.04714.66
5.3.190.0100.05714.63
5.3.180.0000.06014.60
5.3.170.0070.07314.66
5.3.160.0100.04314.76
5.3.150.0130.04314.49
5.3.140.0000.08314.66
5.3.130.0130.03714.75
5.3.120.0070.06314.59
5.3.110.0230.06014.48
5.3.100.0100.07314.11
5.3.90.0030.05014.09
5.3.80.0130.04714.00
5.3.70.0000.04714.01
5.3.60.0170.06714.09
5.3.50.0030.08014.00
5.3.40.0000.04013.98
5.3.30.0070.03713.99
5.3.20.0030.05313.75
5.3.10.0000.03713.62
5.3.00.0030.03713.72
5.2.170.0070.02711.16
5.2.160.0000.03011.36
5.2.150.0070.02711.16
5.2.140.0000.03311.34
5.2.130.0030.02711.16
5.2.120.0000.03011.11
5.2.110.0070.02311.30
5.2.100.0030.03311.20
5.2.90.0000.03311.07
5.2.80.0000.03011.14
5.2.70.0000.03311.03
5.2.60.0000.03011.04
5.2.50.0000.03011.23
5.2.40.0030.03011.04
5.2.30.0000.03010.95
5.2.20.0030.02711.16
5.2.10.0000.03010.79
5.2.00.0100.02010.81
5.1.60.0030.02310.11
5.1.50.0070.02010.02
5.1.40.0000.02710.07
5.1.30.0070.02010.45
5.1.20.0070.02310.55
5.1.10.0030.02310.16
5.1.00.0030.03010.09
5.0.50.0000.0208.58
5.0.40.0000.0208.45
5.0.30.0030.0278.34
5.0.20.0000.0208.17
5.0.10.0000.0208.29
5.0.00.0070.0238.19
4.4.90.0000.0278.04
4.4.80.0000.0208.04
4.4.70.0070.0108.04
4.4.60.0000.0178.04
4.4.50.0030.0138.04
4.4.40.0000.0238.04
4.4.30.0000.0178.04
4.4.20.0000.0178.04
4.4.10.0000.0178.04
4.4.00.0000.0238.04
4.3.110.0000.0138.04
4.3.100.0000.0138.04
4.3.90.0000.0138.04
4.3.80.0000.0238.04
4.3.70.0000.0138.04
4.3.60.0000.0178.04
4.3.50.0070.0108.04
4.3.40.0030.0208.04
4.3.30.0000.0178.04
4.3.20.0000.0138.04
4.3.10.0000.0138.04
4.3.00.0000.0138.04

preferences:
41.17 ms | 401 KiB | 5 Q