add bench, modif imgs, remove loop in benched function
Signed-off-by: Adrien <adrien.ph@gmail.com>
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
// foreach_v() n'est pas dans le graph car son éxecution prends -1% du temps d'éxecution total
|
$array = array('42' => 'The Truth Is Out There', 'json' => 'une case en moins', 'toujours là');
|
||||||
|
|
||||||
$array = array('42' => 'The Truth Is Out There', 'json' => array('toi' => 'une case en moins', 'voir trois'), 'toujours là');
|
|
||||||
|
|
||||||
function foreach_kv()
|
function foreach_kv()
|
||||||
{
|
{
|
||||||
|
@ -36,13 +34,15 @@ function for_k()
|
||||||
global $array;
|
global $array;
|
||||||
|
|
||||||
$key = array_keys($array);
|
$key = array_keys($array);
|
||||||
$size = sizeof($key);
|
$size = count($key);
|
||||||
|
|
||||||
for ($i=0; $i < $size; $i++);
|
for ($i=0; $i < $size; $i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach_kv();
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
foreach_kPv();
|
foreach_kv();
|
||||||
foreach_v();
|
foreach_kPv();
|
||||||
while_k();
|
foreach_v();
|
||||||
for_k();
|
while_k();
|
||||||
|
for_k();
|
||||||
|
}
|
||||||
|
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 42 KiB |
|
@ -0,0 +1,111 @@
|
||||||
|
<?php
|
||||||
|
$str = 'Fallout > 3, is not a Fallout game!';
|
||||||
|
$int = 42;
|
||||||
|
|
||||||
|
function strcEgal()
|
||||||
|
{
|
||||||
|
global $str, $int;
|
||||||
|
|
||||||
|
if ('Fallout > 3, is not a Fallout game!' === $str);
|
||||||
|
if ('The cake is a lie' === $str);
|
||||||
|
|
||||||
|
if (42 === $int);
|
||||||
|
if (24 === $int);
|
||||||
|
if ('24' === $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
function egal()
|
||||||
|
{
|
||||||
|
global $str, $int;
|
||||||
|
|
||||||
|
if ('Fallout > 3, is not a Fallout game!' == $str);
|
||||||
|
if ('The cake is a lie' == $str);
|
||||||
|
|
||||||
|
if (42 == $int);
|
||||||
|
if (24 == $int);
|
||||||
|
if ('24' == $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
function strcdiff()
|
||||||
|
{
|
||||||
|
global $str, $int;
|
||||||
|
|
||||||
|
if ('Fallout > 3, is not a Fallout game!' !== $str);
|
||||||
|
if ('The cake is a lie' !== $str);
|
||||||
|
|
||||||
|
if (42 !== $int);
|
||||||
|
if (24 !== $int);
|
||||||
|
if ('24' !== $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
function diff()
|
||||||
|
{
|
||||||
|
global $str, $int;
|
||||||
|
|
||||||
|
if ('Fallout > 3, is not a Fallout game!' != $str);
|
||||||
|
if ('The cake is a lie' != $str);
|
||||||
|
|
||||||
|
if (42 != $int);
|
||||||
|
if (24 != $int);
|
||||||
|
if ('24' != $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
function strcEgal_cast()
|
||||||
|
{
|
||||||
|
global $str, $int;
|
||||||
|
|
||||||
|
if ((string) 'Fallout > 3, is not a Fallout game!' === $str);
|
||||||
|
if ((string) 'The cake is a lie' === $str);
|
||||||
|
|
||||||
|
if ((int) 42 === $int);
|
||||||
|
if ((int) 24 === $int);
|
||||||
|
if ((string) '24' === $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
function egal_cast()
|
||||||
|
{
|
||||||
|
global $str, $int;
|
||||||
|
|
||||||
|
if ((string) 'Fallout > 3, is not a Fallout game!' == $str);
|
||||||
|
if ((string) 'The cake is a lie' == $str);
|
||||||
|
|
||||||
|
if ((int) 42 == $int);
|
||||||
|
if ((int) 24 == $int);
|
||||||
|
if ((string) '24' == $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
function strcdiff_cast()
|
||||||
|
{
|
||||||
|
global $str, $int;
|
||||||
|
|
||||||
|
if ((string) 'Fallout > 3, is not a Fallout game!' !== $str);
|
||||||
|
if ((string) 'The cake is a lie' !== $str);
|
||||||
|
|
||||||
|
if ((int) 42 !== $int);
|
||||||
|
if ((int) 24 !== $int);
|
||||||
|
if ((string) '24' !== $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
function diff_cast()
|
||||||
|
{
|
||||||
|
global $str, $int;
|
||||||
|
|
||||||
|
if ((string) 'Fallout > 3, is not a Fallout game!' != $str);
|
||||||
|
if ((string) 'The cake is a lie' != $str);
|
||||||
|
|
||||||
|
if ((int) 42 != $int);
|
||||||
|
if ((int) 24 != $int);
|
||||||
|
if ((string) '24' != $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
|
strcEgal();
|
||||||
|
egal();
|
||||||
|
strcEgal_cast();
|
||||||
|
egal_cast();
|
||||||
|
|
||||||
|
strcdiff();
|
||||||
|
diff();
|
||||||
|
strcdiff_cast();
|
||||||
|
diff_cast();
|
||||||
|
}
|
After Width: | Height: | Size: 47 KiB |
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
function ArrayBySelf()
|
||||||
|
{
|
||||||
|
$a = array('Dogmeat', 'Ian', 'compagnon' => 'Katja', 'Tycho');
|
||||||
|
}
|
||||||
|
|
||||||
|
function arrayById()
|
||||||
|
{
|
||||||
|
$a['compagnon'] = 'Katja';
|
||||||
|
$a['0'] = 'Dogmeat';
|
||||||
|
$a['1'] = 'Ian';
|
||||||
|
$a['2'] = 'Tycho';
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
|
ArrayBySelf();
|
||||||
|
arrayById();
|
||||||
|
}
|
After Width: | Height: | Size: 15 KiB |
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
// Global est est utilisé dans toute les fonctions car il serait compté comme temps suplémentaire
|
||||||
|
|
||||||
|
$string = 'je suis un "string" ...';
|
||||||
|
$int = 42;
|
||||||
|
|
||||||
|
function echo_gui()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
echo "je suis une chaine, bastard !";
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_apo()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
echo 'je suis une chaine, bastard !';
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_gui_var()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
echo "je suis une chaine, bastard ! $string de $int";
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_apo_var_dot()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
echo 'je suis une chaine, bastard !'.$string.' de '.$int;
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_apo_var_com()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
echo 'je suis une chaine, bastard !',$string,' de ',$int;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
|
echo_gui();
|
||||||
|
echo_apo();
|
||||||
|
echo_gui_var();
|
||||||
|
echo_apo_var_dot();
|
||||||
|
echo_apo_var_com();
|
||||||
|
}
|
After Width: | Height: | Size: 31 KiB |
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
$string = 'je suis un "string" ...';
|
||||||
|
$int = 42;
|
||||||
|
|
||||||
|
function echo_gui_var()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
echo "$string$int$string$int$string$int$string$int";
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_apo_var_dot()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
echo $string.$int.$string.$int.$string.$int.$string.$int;
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_apo_var_com()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
echo $string,$int,$string,$int,$string,$int,$string,$int;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
|
echo_gui_var();
|
||||||
|
echo_apo_var_dot();
|
||||||
|
echo_apo_var_com();
|
||||||
|
}
|
After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
@ -1,35 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
|
$array = array('foo' => 'bar', 'item', 'Value');
|
||||||
|
|
||||||
function isArray()
|
function isArray()
|
||||||
{
|
{
|
||||||
$iterations = 100000;
|
global $array;
|
||||||
$array = array('foo' => 'bar', 'item', 'Value');
|
|
||||||
|
|
||||||
for ($i = 0; $i < $iterations; ++$i) {
|
if (is_array($array));
|
||||||
if (is_array($array)) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function castArray()
|
function castArray()
|
||||||
{
|
{
|
||||||
$iterations = 100000;
|
global $array;
|
||||||
$array = array('foo' => 'bar', 'item', 'Value');
|
|
||||||
|
|
||||||
for ($i = 0; $i < $iterations; ++$i) {
|
if ((array) $array == $array);
|
||||||
if ((array) $array == $array) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function gettypeArray()
|
function gettypeArray()
|
||||||
{
|
{
|
||||||
$iterations = 100000;
|
global $array;
|
||||||
$array = array('foo' => 'bar', 'item', 'Value');
|
|
||||||
|
|
||||||
for ($i = 0; $i < $iterations; ++$i) {
|
if (gettype($array) == "array");
|
||||||
if (gettype($array) == "array") {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isArray();
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
castArray();
|
isArray();
|
||||||
gettypeArray();
|
castArray();
|
||||||
|
gettypeArray();
|
||||||
|
}
|
||||||
|
|
BIN
php_isArray.png
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 28 KiB |
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
$string = 'je suis un "string" ...';
|
||||||
|
$int = 42;
|
||||||
|
|
||||||
|
function print_B()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
print $string.$int;
|
||||||
|
print 'Blablabla M.Freeman';
|
||||||
|
print 'Blablabla M.Freeman'.$string.$int;
|
||||||
|
}
|
||||||
|
|
||||||
|
function echo_B()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
echo $string.$int;
|
||||||
|
echo 'Blablabla M.Freeman';
|
||||||
|
echo 'Blablabla M.Freeman'.$string.$int;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sprintf_B()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
sprintf("%s%d", $string, $int);
|
||||||
|
sprintf("Blablabla M.Freeman");
|
||||||
|
sprintf("Blablabla M.Freeman %s%d", $string, $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
function printf_B()
|
||||||
|
{
|
||||||
|
global $string, $int;
|
||||||
|
|
||||||
|
printf("%s%d", $string, $int);
|
||||||
|
printf("Blablabla M.Freeman");
|
||||||
|
printf("Blablabla M.Freeman %s%d", $string, $int);
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
|
print_B();
|
||||||
|
echo_B();
|
||||||
|
sprintf_B();
|
||||||
|
printf_B();
|
||||||
|
}
|
After Width: | Height: | Size: 33 KiB |
|
@ -4,7 +4,7 @@ function implodeArr()
|
||||||
$string = '';
|
$string = '';
|
||||||
$array = array();
|
$array = array();
|
||||||
|
|
||||||
for ($i = 0; $i < 100000; ++$i) {
|
for ($i = 0; $i < 100; ++$i) {
|
||||||
$array[] = 'MyLittlePony != 42 ';
|
$array[] = 'MyLittlePony != 42 ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ function classic()
|
||||||
{
|
{
|
||||||
$string = '';
|
$string = '';
|
||||||
|
|
||||||
for ($i = 0; $i < 100000; ++$i) {
|
for ($i = 0; $i < 100; ++$i) {
|
||||||
$string .= 'MyLittlePony != 42 ';
|
$string .= 'MyLittlePony != 42 ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,13 @@ function reDefinition()
|
||||||
{
|
{
|
||||||
$string = '';
|
$string = '';
|
||||||
|
|
||||||
for ($i = 0; $i < 100000; ++$i) {
|
for ($i = 0; $i < 100; ++$i) {
|
||||||
$string == $string.'MyLittlePony != 42 ';
|
$string == $string.'MyLittlePony != 42 ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
implodeArr();
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
classic();
|
implodeArr();
|
||||||
reDefinition();
|
classic();
|
||||||
|
reDefinition();
|
||||||
|
}
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 25 KiB |
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
function if_A()
|
||||||
|
{
|
||||||
|
if (false) {}
|
||||||
|
elseif (false) {}
|
||||||
|
else {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function if_B()
|
||||||
|
{
|
||||||
|
if (false) {}
|
||||||
|
elseif (false) {}
|
||||||
|
elseif (false) {}
|
||||||
|
elseif (false) {}
|
||||||
|
elseif (false) {}
|
||||||
|
else {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function if_C()
|
||||||
|
{
|
||||||
|
if (false) {}
|
||||||
|
if (false) {}
|
||||||
|
if (false) {}
|
||||||
|
if (false) {}
|
||||||
|
if (false) {}
|
||||||
|
else {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function switch_A()
|
||||||
|
{
|
||||||
|
switch (true) {
|
||||||
|
case false: break;
|
||||||
|
case false: break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function switch_B()
|
||||||
|
{
|
||||||
|
switch (true) {
|
||||||
|
case false: break;
|
||||||
|
case false: break;
|
||||||
|
case false: break;
|
||||||
|
case false: break;
|
||||||
|
case false: break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
|
if_A();
|
||||||
|
if_B();
|
||||||
|
if_C();
|
||||||
|
switch_A();
|
||||||
|
switch_B();
|
||||||
|
}
|
After Width: | Height: | Size: 27 KiB |
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
function null_B()
|
||||||
|
{
|
||||||
|
$a = 'athos porthos aramis';
|
||||||
|
$b = array('athos' => 'Milady de Winter', 'Haaa les femmes ...');
|
||||||
|
|
||||||
|
$a = NULL;
|
||||||
|
$b['athos'] = NULL;
|
||||||
|
$b['0'] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unset_B()
|
||||||
|
{
|
||||||
|
$a = 'athos porthos aramis';
|
||||||
|
$b = array('athos' => 'Milady de Winter', 'Haaa les femmes ...');
|
||||||
|
|
||||||
|
unset($a);
|
||||||
|
unset($b['athos']);
|
||||||
|
unset($b['0']);
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i = 0; $i < 100000; $i++) {
|
||||||
|
null_B();
|
||||||
|
unset_B();
|
||||||
|
}
|
After Width: | Height: | Size: 14 KiB |