3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace model; /** * [[ * __table = catalog * __order = parentid, sort, id * __primary = id * __editable = title, name, parentid, status, sort * __listable = id, title, status * id = int catid * name = string catname * title = string cattitle * parentid = int catparent * status = bool catstatus * sort = int catsort * minorder = int catminorder * * fullpath = string * url = object * remainder = array * ]] */ class Catalog extends Model implements Structural { protected function init() { $this->registerFieldCallback('fullpath', 'makeFullPath'); $this->registerFieldCallback('url', 'makeURL'); if(!defined('ADMIN_MODE')) $this->addRestriction('status', '>', 0); } function prepareGet() { $this->update(); } function get($selector) // string path || string fullpath || numeric id || array fullpath { // $this->db->debugOn(); $this->prepareGet(); //if(empty($selector)) return $this; if(is_array($selector)) { $pid = 0; $remainder = null; foreach($selector as $path) { if(empty($path)) continue; if(!empty($remainder)) { array_push($remainder, $path); continue; } $this->prepareGet(); $this->parentid = $pid; $this->name = $path; $rslt = $this->db->select($this->getJunction(), '*', $this->makeArray(self::CHANGED|self::PREDICATES, true), null, 1); if($rslt && mysql_num_rows($rslt) > 0) { $this->newResult($rslt); } else { $this->prepareGet(); // We changed path and parent before, resetting $remainder = array($path); continue; } if(!$this->hasResult()) break; $pid = $this->id; } if($remainder) { $this->remainder = $remainder; } return $this; } elseif(is_numeric($selector)) { $this->id = intval($selector); } elseif(is_object($selector)) { $this->id = $selector->sectionid; } else { $newselector = explode('/', $selector); if(count($newselector) > 1) return $this->get($newselector); $this->fullpath = $selector; } $this->fetch(); return $this; } function restrictToBrand(Manufacturer $mf) { $this->setJunction('INNER JOIN mf_in_cat USING (catid)', true); $this->addRestriction('mfid', '=', $mf->id); } function getDescendantIds($and_self=false, $recursive=false, $secid=null) /* TODO: recursive */ { if(is_null($secid)) $secid = $this->id; $ids = $and_self ? array($secid) : array(); $where = array($this->unalias('parentid') => $secid); $sort = $this->unalias($this->getDefaultOrder()); $rslt = $this->db->select($this->getTable(), $this->unalias('id'), $where, $sort); if($rslt) while($r = mysql_fetch_row($rslt)) { $ids[] = $r[0]; if($recursive) $ids = array_merge($ids, $this->getDescendantIds(false, true, $r[0])); } return $ids; } function firstChild() { $id = $this->id; $this->prepareGet(); $this->parentid = $id; $this->fetch(); return $this; } function getFirst() { $this->prepareGet(); $this->fetch(); return $this; } /* Structural interface */ function getPath() { return $this->name; } function getFullPath() { return $this->fullpath; } function getTitle() { return $this->title; } function getByPath($path) { return $this->get($path); } function getTopLevel() { $this->prepareGet(); $this->parentid = 0; $this->fetchList(); return $this; } function getChildren() { $id = $this->id; $this->prepareGet(); $this->parentid = $id; $this->fetchList(); return $this; } function getParent() { return $this->get($this->parentid); } function hasParent() { return $this->parentid > 0; } /* Callbacks */ protected function makeFullPath() { $ancestor = clone $this; if($ancestor->hasParent() && $ancestor->getParent() && $ancestor->hasResult()) { $fullpath = $ancestor->fullpath . $this->name . '/'; } else { if(defined('ADMIN_MODE')) $fullpath = '/'.$this->name.'/'; // I can't express how bad it is :( else $fullpath = '/catalog/'.$this->name.'/'; } return $fullpath; } protected function makeURL() { return new \helper\URL($this->fullpath); } } ?>

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.70.0070.01116.61
8.3.60.0100.00718.68
8.3.50.0080.01122.05
8.3.40.0100.01418.84
8.3.30.0070.00718.97
8.3.20.0050.00320.16
8.3.10.0000.01323.56
8.3.00.0040.00420.67
8.2.180.0160.00016.75
8.2.170.0040.01122.96
8.2.160.0080.00522.21
8.2.150.0080.00024.18
8.2.140.0000.00824.66
8.2.130.0000.00826.16
8.2.120.0040.00421.05
8.2.110.0030.00622.07
8.2.100.0040.00718.03
8.2.90.0000.00819.25
8.2.80.0000.00817.97
8.2.70.0000.00817.88
8.2.60.0080.00018.05
8.2.50.0000.00918.07
8.2.40.0040.00418.34
8.2.30.0040.00718.14
8.2.20.0050.00317.89
8.2.10.0040.00417.75
8.2.00.0040.00417.71
8.1.280.0120.00925.92
8.1.270.0040.00423.91
8.1.260.0030.00626.35
8.1.250.0070.00028.09
8.1.240.0030.00623.82
8.1.230.0070.00419.36
8.1.220.0040.00417.79
8.1.210.0060.00318.77
8.1.200.0090.00017.48
8.1.190.0000.00817.38
8.1.180.0080.00018.10
8.1.170.0080.00018.56
8.1.160.0040.00422.11
8.1.150.0000.00818.71
8.1.140.0030.00617.45
8.1.130.0070.00017.86
8.1.120.0000.00717.48
8.1.110.0070.00017.38
8.1.100.0000.00717.38
8.1.90.0070.00017.49
8.1.80.0000.00817.47
8.1.70.0070.00017.46
8.1.60.0060.00317.59
8.1.50.0030.00617.57
8.1.40.0050.00317.56
8.1.30.0040.00417.71
8.1.20.0000.00817.62
8.1.10.0030.00617.49
8.1.00.0000.00817.46
8.0.300.0070.00018.77
8.0.290.0000.00717.30
8.0.280.0000.00718.48
8.0.270.0000.00717.26
8.0.260.0070.00016.91
8.0.250.0000.00716.99
8.0.240.0070.00317.13
8.0.230.0030.00517.00
8.0.220.0070.00017.04
8.0.210.0040.00416.94
8.0.200.0070.00017.15
8.0.190.0000.00717.10
8.0.180.0000.00716.98
8.0.170.0050.00516.97
8.0.160.0050.00316.95
8.0.150.0030.00616.89
8.0.140.0040.00417.01
8.0.130.0060.00013.47
8.0.120.0080.00017.01
8.0.110.0040.00417.02
8.0.100.0040.00417.00
8.0.90.0000.00817.04
8.0.80.0130.00417.11
8.0.70.0070.00017.11
8.0.60.0040.00417.02
8.0.50.0030.00516.88
8.0.30.0150.00917.29
8.0.20.0110.00817.40
8.0.10.0040.00417.06
8.0.00.0110.00917.02
7.4.330.0050.00015.03
7.4.320.0030.00316.56
7.4.300.0040.00416.55
7.4.290.0070.00016.60
7.4.280.0000.00816.57
7.4.270.0030.00316.59
7.4.260.0000.00716.63
7.4.250.0040.00416.61
7.4.240.0040.00316.51
7.4.230.0000.00716.70
7.4.220.0110.01316.48
7.4.210.0080.00816.53
7.4.200.0030.00316.44
7.4.190.0070.00016.79
7.4.160.0140.00416.54
7.4.150.0140.00617.40
7.4.140.0110.00617.86
7.4.130.0110.00516.61
7.4.120.0120.00916.39
7.4.110.0070.01016.66
7.4.100.0090.00916.54
7.4.90.0110.00616.79
7.4.80.0110.00616.68
7.4.70.0080.00816.61
7.4.60.0060.01016.59
7.4.50.0040.00416.50
7.4.40.0130.00322.77
7.4.30.0100.01016.33
7.4.10.0070.01015.09
7.4.00.0060.01115.02
7.3.330.0040.00413.37
7.3.320.0000.00613.37
7.3.310.0050.00216.41
7.3.300.0030.00316.20
7.3.290.0050.01016.41
7.3.280.0130.00616.40
7.3.270.0080.01017.40
7.3.260.0130.01016.46
7.3.250.0120.00916.53
7.3.240.0140.00416.45
7.3.230.0100.01016.46
7.3.210.0030.01916.59
7.3.200.0120.00919.39
7.3.190.0130.00316.42
7.3.180.0090.00816.25
7.3.170.0100.00616.39
7.3.160.0060.01016.70
7.3.130.0130.00414.95
7.3.120.0040.00814.85
7.3.110.0060.01314.70
7.3.100.0100.00614.88
7.3.90.0040.01114.73
7.3.80.0030.00814.62
7.3.70.0040.01214.87
7.3.60.0060.01014.86
7.3.50.0000.01014.61
7.3.40.0000.01414.46
7.3.30.0060.01214.75
7.3.20.0100.00316.40
7.3.10.0120.00016.18
7.3.00.0090.00616.59
7.2.330.0190.00016.74
7.2.320.0120.00416.63
7.2.310.0030.01416.38
7.2.300.0040.01216.35
7.2.290.0030.01316.58
7.2.260.0030.01914.71
7.2.250.0080.01214.84
7.2.240.0070.00714.88
7.2.230.0070.00715.15
7.2.220.0000.01514.86
7.2.210.0070.00414.53
7.2.200.0100.00315.04
7.2.190.0000.01815.14
7.2.180.0030.00914.62
7.2.170.0130.00315.01
7.2.160.0060.01214.73
7.2.150.0070.00716.46
7.2.140.0060.00916.66
7.2.130.0030.00716.56
7.2.120.0140.00316.38
7.2.110.0080.00316.63
7.2.100.0090.00616.76
7.2.90.0030.01216.48
7.2.80.0030.00916.73
7.2.70.0120.00316.50
7.2.60.0090.00616.35
7.2.50.0060.01016.38
7.2.40.0070.00716.63
7.2.30.0090.00916.93
7.2.20.0080.00316.82
7.2.10.0120.00316.80
7.2.00.0030.00818.12
7.1.330.0060.00915.50
7.1.320.0110.00715.20
7.1.310.0110.00415.32
7.1.300.0110.00615.47
7.1.290.0050.00315.58
7.1.280.0100.00715.18
7.1.270.0100.00715.18
7.1.260.0060.00315.43
7.1.250.0030.00715.32
7.1.240.0040.01415.39
7.1.230.0000.01515.59
7.1.220.0060.01015.36
7.1.210.0030.01015.38
7.1.200.0070.00715.54
7.1.190.0070.00715.54
7.1.180.0000.01515.38
7.1.170.0040.01115.35
7.1.160.0000.01315.54
7.1.150.0000.00915.59
7.1.140.0070.00715.50
7.1.130.0100.00315.39
7.1.120.0000.01215.49
7.1.110.0070.00715.54
7.1.100.0000.01316.77
7.1.90.0080.00315.76
7.1.80.0060.00915.36
7.1.70.0050.00716.32
7.1.60.0050.01317.49
7.1.50.0050.01416.17
7.1.40.0060.00315.64
7.1.30.0040.00815.46
7.1.20.0040.00815.30
7.1.10.0130.00315.64
7.1.00.0030.04518.94
7.0.330.0110.00415.31
7.0.320.0090.00014.82
7.0.310.0080.00015.21
7.0.300.0050.00515.14
7.0.290.0060.00615.13
7.0.280.0070.00715.00
7.0.270.0080.00414.94
7.0.260.0090.00315.17
7.0.250.0070.00314.84
7.0.240.0130.00015.28
7.0.230.0070.00315.09
7.0.220.0030.01015.11
7.0.210.0070.00315.23
7.0.200.0030.00815.81
7.0.190.0060.00315.46
7.0.180.0030.00915.02
7.0.170.0030.00614.94
7.0.160.0060.00615.24
7.0.150.0070.00715.20
7.0.140.0050.04118.53
7.0.130.0070.00415.08
7.0.120.0090.00615.05
7.0.110.0030.00915.15
7.0.100.0080.04317.64
7.0.90.0030.04617.63
7.0.80.0160.02517.66
7.0.70.0180.04017.55
7.0.60.0180.04517.58
7.0.50.0240.04217.82
7.0.40.0100.02216.52
7.0.30.0040.03216.60
7.0.20.0100.03816.74
7.0.10.0080.04616.62
7.0.00.0090.04116.64
5.6.400.0070.00714.24
5.6.390.0060.01214.29
5.6.380.0080.00614.39
5.6.370.0070.00713.90
5.6.360.0030.01014.36
5.6.350.0030.01314.20
5.6.340.0000.00914.42
5.6.330.0000.01414.50
5.6.320.0000.01314.38
5.6.310.0110.00414.19
5.6.300.0040.01114.63
5.6.290.0070.01114.21
5.6.280.0050.03917.66
5.6.270.0040.00713.84
5.6.260.0130.00314.30
5.6.250.0100.03217.46
5.6.240.0040.04417.57
5.6.230.0120.04017.50
5.6.220.0050.04217.38
5.6.210.0090.03117.45
5.6.200.0050.03517.53
5.6.190.0030.04817.59
5.6.180.0050.03617.56
5.6.170.0030.02617.73
5.6.160.0120.03717.70
5.6.150.0050.03517.60
5.6.140.0080.02817.65
5.6.130.0100.04017.76
5.6.120.0050.04517.70
5.6.110.0060.04317.57
5.6.100.0050.04617.62
5.6.90.0080.03517.74
5.6.80.0090.03517.41
5.6.70.0090.04117.24
5.6.60.0040.04017.37
5.6.50.0070.04117.25
5.6.40.0030.04517.27
5.6.30.0090.04017.28
5.6.20.0050.03817.18
5.6.10.0020.04917.36
5.6.00.0020.03317.20
5.5.380.0080.04017.26
5.5.370.0100.04017.43
5.5.360.0060.04617.45
5.5.350.0050.02917.30
5.5.340.0050.04817.67
5.5.330.0050.03117.35
5.5.320.0170.01817.36
5.5.310.0050.04517.57
5.5.300.0070.03817.60
5.5.290.0050.04317.32
5.5.280.0070.04317.43
5.5.270.0080.04517.44
5.5.260.0150.03817.58
5.5.250.0060.03917.28
5.5.240.0100.03317.26
5.5.230.0080.03917.06
5.5.220.0080.04317.11
5.5.210.0050.04817.01
5.5.200.0050.04617.13
5.5.190.0050.03317.12
5.5.180.0080.03117.20
5.5.170.0000.00913.87
5.5.160.0050.02717.09
5.5.150.0040.04917.24
5.5.140.0030.03917.08
5.5.130.0140.02817.02
5.5.120.0100.04217.16
5.5.110.0070.03717.16
5.5.100.0050.04417.07
5.5.90.0080.03017.09
5.5.80.0030.03717.09
5.5.70.0050.04316.93
5.5.60.0060.03816.97
5.5.50.0100.04217.01
5.5.40.0100.03817.06
5.5.30.0070.03917.04
5.5.20.0050.03417.13
5.5.10.0050.03517.07
5.5.00.0030.03716.98
5.4.450.0050.04615.24
5.4.440.0060.02814.92
5.4.430.0030.04315.04
5.4.420.0050.04315.07
5.4.410.0050.02215.00
5.4.400.0020.04315.07
5.4.390.0110.04014.94
5.4.380.0030.04214.75
5.4.370.0150.03515.05
5.4.360.0050.04115.03
5.4.350.0100.03414.95
5.4.340.0110.03015.03
5.4.330.0040.00810.93
5.4.320.0030.02415.00
5.4.310.0050.02514.94
5.4.300.0040.04314.87
5.4.290.0070.02814.84
5.4.280.0030.02214.95
5.4.270.0030.04314.92
5.4.260.0060.02314.97
5.4.250.0030.04215.09
5.4.240.0050.04014.97
5.4.230.0080.02314.90
5.4.220.0050.04014.85
5.4.210.0130.02514.97
5.4.200.0050.02614.90
5.4.190.0040.02414.80
5.4.180.0070.03515.04
5.4.170.0030.03614.76
5.4.160.0050.03814.74
5.4.150.0090.03514.66
5.4.140.0060.03613.52
5.4.130.0090.03813.61
5.4.120.0050.01813.70
5.4.110.0030.03113.52
5.4.100.0050.02313.56
5.4.90.0000.03313.58
5.4.80.0060.04013.56
5.4.70.0050.03813.59
5.4.60.0050.04313.67
5.4.50.0020.03713.70
5.4.40.0070.04013.59
5.4.30.0100.03513.64
5.4.20.0050.03913.59
5.4.10.0000.03113.63
5.4.00.0120.03313.37
5.3.290.0030.02312.65
5.3.280.0070.03512.53
5.3.270.0050.03612.60
5.3.260.0080.02712.50
5.3.250.0110.03312.60
5.3.240.0070.03112.34
5.3.230.0110.02412.40
5.3.220.0080.04212.53
5.3.210.0070.03312.52
5.3.200.0030.02812.50
5.3.190.0050.03012.57
5.3.180.0100.03312.54
5.3.170.0030.03112.44
5.3.160.0020.04112.53
5.3.150.0030.04512.43
5.3.140.0100.02712.44
5.3.130.0020.02612.53
5.3.120.0020.02812.38
5.3.110.0060.03812.54
5.3.100.0050.03512.39
5.3.90.0050.03912.30
5.3.80.0070.03512.16
5.3.70.0020.04412.23
5.3.60.0050.03712.08
5.3.50.0040.02612.21
5.3.40.0000.05011.96
5.3.30.0080.03112.19
5.3.20.0040.03611.82
5.3.10.0070.03911.87
5.3.00.0050.03011.90

preferences:
48.23 ms | 401 KiB | 5 Q