3v4l.org

run code in 300+ PHP versions simultaneously
<?php /******************************* * author : hishamdalal@gmail.com * version : 3.1 * date : 2013-04-11 *****************************/ class overloadable { protected $fname = null; protected $fargs = array(); //--------------------------------------------------// function set($obj, $fname, $args){ $n = ''; $type = $this->getType($args); $n = "\$o = new $obj();\n"; $n .= "if(method_exists(\$o, '$fname"."_$type')){\n"; $n .= "\t\$r = \$o->$fname"."_$type(". $this->getArgsName($args) .");\n"; $n .= "}else{\n\t\$r = null;\n"; $n .= "\ttrigger_error('function ".$fname."_".$type." is not exist!');\n}"; eval("\$r = $n;"); return $r; } //--------------------------------------------------// function getType($args) { $argType = array(); foreach($args as $i=>$val) { $argType[$i][] = $this->getSuffix($val, $i) ; } $s = ''; if(is_array($argType)){ foreach($argType as $type){ $s .= implode('', $type); } return $s; } return implode('', $argType); } //--------------------------------------------------// function getSuffix($byValarg, $i) { if( is_numeric($byValarg) ) { $type = 'N'; $this->fargs['N'.$i] = $byValarg; } elseif( is_array($byValarg) ) { $type = 'A'; $this->fargs['A'.$i] = $byValarg; } elseif( is_object($byValarg) ) { $type = 'O'; $this->fargs['O'.$i] = $byValarg; } elseif( is_resource($byValarg) ) { $type = 'R'; $this->fargs['R'.$i] = $byValarg; } else { $type = 'S'; $this->fargs['S'.$i] = $byValarg; } return $type; } //--------------------------------------------------// function getArgsName($args){ $r = array(); $ary = array_keys($this->fargs); foreach( $ary as $k=>$v){ $r[]='$this->fargs["'.$v.'"]'; } return implode(", ", $r); } //--------------------------------------------------// function __call($name, $args){ $this->fargs = array(); return $this->set(get_class($this), $name, $args); } //--------------------------------------------------// } class test2 extends overloadable { function foo_(){ echo 'foo - no args'; } function foo_S($s){ echo "foo - one string $s"; } function foo_SS($s1, $s2){ echo "foo - tow strings $s1, $s2"; } function foo_SN($s, $n){ echo "foo - string and number $s, $n"; } function foo_A($ary){ print_r($ary); } function foo_AA($ary1, $ary2){ if(is_array($ary1) && is_array($ary2)){ echo "foo - tow arrays"; }else{echo 0;} } function foo_O($obj){ echo "foo - "; print_r($obj); } function hi(){ echo "hi - welcome!"; } } echo '<pre>'; $t = new test2(); echo '<br />foo_: '; print_r( $t->foo() ); echo '<br />foo_s: '; print_r( $t->foo('a') ); echo '<br />foo_ss: '; print_r( $t->foo('a', 'b') ); echo '<br />foo_sn: '; print_r( $t->foo('a', 2) ); echo '<br />foo_snn: '; print_r( $t->foo('s', 2, 9) ); echo '<br />foo_a: '; print_r( $t->foo(array(4,5,6,7)) ); echo '<br />foo_aa: '; print_r( $t->foo( array(5,6,7), array(8,9,10) ) ); echo '<br />foo_o: '; print_r( $t->foo($t) ); echo '<br />hi: '; print_r( $t->hi() ); ?>

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.0070.00718.68
8.3.50.0100.01021.15
8.3.40.0070.01118.84
8.3.30.0120.00319.18
8.3.20.0080.00020.29
8.3.10.0000.01422.09
8.3.00.0030.00520.73
8.2.180.0180.00316.63
8.2.170.0080.01122.96
8.2.160.0150.00019.27
8.2.150.0090.00924.18
8.2.140.0040.00424.66
8.2.130.0030.00526.16
8.2.120.0060.00319.48
8.2.110.0090.00021.99
8.2.100.0060.00619.33
8.2.90.0000.00819.34
8.2.80.0080.00019.41
8.2.70.0000.01017.75
8.2.60.0040.00418.18
8.2.50.0000.00818.07
8.2.40.0080.00018.16
8.2.30.0000.00818.23
8.2.20.0080.00017.82
8.2.10.0040.00417.83
8.2.00.0040.00817.79
8.1.280.0230.00725.92
8.1.270.0030.01322.31
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00323.99
8.1.230.0030.00919.29
8.1.220.0040.00417.78
8.1.210.0080.00018.77
8.1.200.0040.00417.47
8.1.190.0030.00617.53
8.1.180.0030.00618.86
8.1.170.0000.00818.60
8.1.160.0040.00422.22
8.1.150.0040.00418.79
8.1.140.0030.00517.60
8.1.130.0040.00417.98
8.1.120.0000.00817.47
8.1.110.0080.00017.45
8.1.100.0050.00317.43
8.1.90.0040.00417.56
8.1.80.0040.00417.46
8.1.70.0040.00417.52
8.1.60.0040.00417.69
8.1.50.0030.00517.61
8.1.40.0040.00417.59
8.1.30.0040.00417.56
8.1.20.0030.00617.71
8.1.10.0000.00717.54
8.1.00.0040.00417.49
8.0.300.0040.00418.77
8.0.290.0030.00517.28
8.0.280.0000.00718.53
8.0.270.0000.00717.35
8.0.260.0030.00316.98
8.0.250.0030.00517.01
8.0.240.0030.00617.08
8.0.230.0040.00417.13
8.0.220.0080.00016.94
8.0.210.0050.00317.05
8.0.200.0050.00217.11
8.0.190.0000.00817.07
8.0.180.0070.00017.11
8.0.170.0090.00016.97
8.0.160.0040.00417.10
8.0.150.0070.00016.95
8.0.140.0000.00816.94
8.0.130.0000.00613.49
8.0.120.0030.00517.08
8.0.110.0070.00016.96
8.0.100.0040.00416.99
8.0.90.0080.00017.04
8.0.80.0130.00417.04
8.0.70.0040.00417.12
8.0.60.0040.00817.03
8.0.50.0000.00816.96
8.0.30.0070.01317.29
8.0.20.0050.01417.40
8.0.10.0040.00417.27
8.0.00.0090.01617.13
7.4.330.0000.00615.00
7.4.320.0070.00016.55
7.4.300.0060.00016.61
7.4.290.0040.00416.73
7.4.280.0070.00016.59
7.4.270.0070.00016.60
7.4.260.0030.00716.59
7.4.250.0000.00816.61
7.4.240.0000.00716.61
7.4.230.0000.00716.55
7.4.220.0150.00316.71
7.4.210.0070.00816.61
7.4.200.0040.00416.75
7.4.190.0070.00016.84
7.4.160.0140.00316.42
7.4.150.0120.00917.40
7.4.140.0050.01417.86
7.4.130.0090.00916.68
7.4.120.0070.01516.59
7.4.110.0070.01016.65
7.4.100.0120.01016.58
7.4.90.0110.00816.56
7.4.80.0070.01119.39
7.4.70.0100.01016.42
7.4.60.0100.01016.57
7.4.50.0000.00816.40
7.4.40.0000.01422.77
7.4.30.0180.00816.63
7.4.00.0040.01215.00
7.3.330.0000.00513.48
7.3.320.0030.00313.38
7.3.310.0000.00816.33
7.3.300.0070.00016.58
7.3.290.0110.00316.45
7.3.280.0110.00516.52
7.3.270.0070.01217.40
7.3.260.0140.00916.51
7.3.250.0110.01016.60
7.3.240.0090.00916.52
7.3.230.0030.01616.57
7.3.210.0140.00416.42
7.3.200.0070.01316.79
7.3.190.0060.01216.46
7.3.180.0160.00016.47
7.3.170.0130.00316.52
7.3.160.0090.00916.63
7.3.120.0030.01515.08
7.3.10.0030.00916.78
7.3.00.0040.00816.68
7.2.330.0100.01016.98
7.2.320.0050.01516.75
7.2.310.0090.00917.00
7.2.300.0080.01116.82
7.2.290.0090.00916.55
7.2.130.0070.00717.09
7.2.120.0100.00716.99
7.2.110.0070.00716.92
7.2.100.0100.00316.81
7.2.90.0110.00717.08
7.2.80.0120.00317.04
7.2.70.0030.00717.21
7.2.60.0100.00317.03
7.2.50.0060.00917.03
7.2.40.0030.01017.03
7.2.30.0120.00317.03
7.2.20.0070.00716.91
7.2.10.0000.01416.93
7.2.00.0050.01018.10
7.1.250.0100.00715.56
7.1.100.0030.00917.98
7.1.70.0040.00417.26
7.1.60.0070.01719.82
7.1.50.0030.02217.11
7.1.00.0000.03722.57
7.0.200.0030.01016.82
7.0.140.0070.07022.23
7.0.100.0070.04019.98
7.0.90.0000.04720.07
7.0.80.0100.05019.97
7.0.70.0070.04320.02
7.0.60.0070.05719.93
7.0.50.0170.04020.32
7.0.40.0030.04320.07
7.0.30.0070.06320.11
7.0.20.0100.08019.95
7.0.10.0100.04320.10
7.0.00.0130.08319.99
5.6.280.0100.06721.07
5.6.250.0000.04720.68
5.6.240.0030.07020.64
5.6.230.0030.04020.79
5.6.220.0030.04020.66
5.6.210.0000.04320.71
5.6.200.0070.08021.12
5.6.190.0130.03321.13
5.6.180.0100.05321.21
5.6.170.0030.04020.96
5.6.160.0270.06721.09
5.6.150.0070.08721.16
5.6.140.0100.07721.05
5.6.130.0030.05321.10
5.6.120.0100.08021.13
5.6.110.0130.07721.09
5.6.100.0200.03720.98
5.6.90.0230.05721.13
5.6.80.0000.04720.46
5.6.70.0000.07320.40
5.6.60.0030.08320.36
5.6.50.0070.07320.48
5.6.40.0100.06320.37
5.6.30.0000.05320.50
5.6.20.0070.08020.41
5.6.10.0100.07720.42
5.6.00.0130.07320.56
5.5.380.0000.04320.50
5.5.370.0000.04320.50
5.5.360.0100.05320.58
5.5.350.0170.02720.43
5.5.340.0030.04320.93
5.5.330.0030.04320.98
5.5.320.0130.05720.78
5.5.310.0030.08320.77
5.5.300.0170.06020.94
5.5.290.0030.08720.85
5.5.280.0100.08020.78
5.5.270.0070.08320.89
5.5.260.0070.08320.77
5.5.250.0070.08020.68
5.5.240.0070.08320.36
5.5.230.0130.07020.25
5.5.220.0070.06320.19
5.5.210.0100.07320.07
5.5.200.0100.06320.30
5.5.190.0070.08320.13
5.5.180.0030.08020.23
5.5.160.0170.07020.27
5.5.150.0100.07320.25
5.5.140.0030.07320.17
5.5.130.0130.06720.03
5.5.120.0070.07720.25
5.5.110.0000.08720.20
5.5.100.0130.07319.98
5.5.90.0130.07320.11
5.5.80.0030.06020.06
5.5.70.0070.08320.11
5.5.60.0070.07720.19
5.5.50.0070.07720.01
5.5.40.0100.07719.99
5.5.30.0000.08320.07
5.5.20.0200.06320.10
5.5.10.0000.08720.04
5.5.00.0070.08020.13
5.4.450.0070.07719.45
5.4.440.0100.07019.36
5.4.430.0100.04319.27
5.4.420.0070.08019.50
5.4.410.0100.06719.40
5.4.400.0070.06319.22
5.4.390.0100.07019.25
5.4.380.0100.07019.04
5.4.370.0070.07318.85
5.4.360.0030.07719.22
5.4.350.0170.06719.17
5.4.340.0130.08019.04
5.4.320.0100.08019.13
5.4.310.0170.07019.10
5.4.300.0000.07318.96
5.4.290.0030.07319.16
5.4.280.0100.07719.03
5.4.270.0070.07319.12
5.4.260.0000.08319.12
5.4.250.0200.07318.85
5.4.240.0100.07318.84
5.4.230.0170.06719.18
5.4.220.0100.06719.03
5.4.210.0130.07018.81
5.4.200.0070.07719.12
5.4.190.0070.06318.88
5.4.180.0030.07319.18
5.4.170.0070.04319.09
5.4.160.0070.07319.02
5.4.150.0230.06019.20
5.4.140.0000.07316.46
5.4.130.0000.08316.32
5.4.120.0070.03016.23
5.4.110.0130.06716.45
5.4.100.0070.06716.33
5.4.90.0030.05316.57
5.4.80.0000.07716.53
5.4.70.0100.07016.37
5.4.60.0030.06716.55
5.4.50.0030.08016.42
5.4.40.0070.08016.46
5.4.30.0100.07316.37
5.4.20.0100.06316.37
5.4.10.0100.07016.48
5.4.00.0100.06315.91
5.3.290.0030.08314.84
5.3.280.0070.07714.64
5.3.270.0100.06714.73
5.3.260.0070.07314.73
5.3.250.0070.07014.73
5.3.240.0130.06014.66
5.3.230.0070.05714.80
5.3.220.0070.07014.69
5.3.210.0030.07714.70
5.3.200.0100.04314.74
5.3.190.0070.07714.77
5.3.180.0000.08014.72
5.3.170.0030.05714.77
5.3.160.0000.08714.73
5.3.150.0070.04714.62
5.3.140.0100.07314.57
5.3.130.0100.07314.57
5.3.120.0100.04314.75
5.3.110.0200.06714.64
5.3.100.0070.08014.24
5.3.90.0030.06014.07
5.3.80.0100.06014.08
5.3.70.0130.05314.02
5.3.60.0070.05714.07
5.3.50.0030.06714.04
5.3.40.0030.07314.13
5.3.30.0100.07714.04
5.3.20.0130.06713.69
5.3.10.0070.07013.83
5.3.00.0130.07013.63

preferences:
43.43 ms | 401 KiB | 5 Q