add bench, modif imgs, remove loop in benched function

Signed-off-by: Adrien <adrien.ph@gmail.com>
master
Adrien 7 years ago
parent c78947432a
commit 4121981e3e
  1. 18
      php_arrayLoop.php
  2. BIN
      php_arrayLoop.png
  3. 111
      php_comparisonOperators.php
  4. BIN
      php_comparisonOperators.png
  5. 18
      php_deffineArray.php
  6. BIN
      php_deffineArray.png
  7. 48
      php_echo.php
  8. BIN
      php_echo.png
  9. 30
      php_echo_multiVar.php
  10. BIN
      php_echo_multiVar.png
  11. BIN
      php_globalVariables.png
  12. 30
      php_isArray.php
  13. BIN
      php_isArray.png
  14. 46
      php_outputAString.php
  15. BIN
      php_outputAString.png
  16. 14
      php_stringConcatenation.php
  17. BIN
      php_stringConcaténation.png
  18. 56
      php_switch.php
  19. BIN
      php_switch.png
  20. 25
      php_unset.php
  21. BIN
      php_unset.png

@ -1,7 +1,5 @@
<?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' => array('toi' => 'une case en moins', 'voir trois'), 'toujours là');
$array = array('42' => 'The Truth Is Out There', 'json' => 'une case en moins', 'toujours là');
function foreach_kv()
{
@ -36,13 +34,15 @@ function for_k()
global $array;
$key = array_keys($array);
$size = sizeof($key);
$size = count($key);
for ($i=0; $i < $size; $i++);
}
foreach_kv();
foreach_kPv();
foreach_v();
while_k();
for_k();
for ($i = 0; $i < 100000; $i++) {
foreach_kv();
foreach_kPv();
foreach_v();
while_k();
for_k();
}

Binary file not shown.

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();
}

Binary file not shown.

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();
}

Binary file not shown.

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();
}

Binary file not shown.

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();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

@ -1,35 +1,29 @@
<?php
$array = array('foo' => 'bar', 'item', 'Value');
function isArray()
{
$iterations = 100000;
$array = array('foo' => 'bar', 'item', 'Value');
global $array;
for ($i = 0; $i < $iterations; ++$i) {
if (is_array($array)) {}
}
if (is_array($array));
}
function castArray()
{
$iterations = 100000;
$array = array('foo' => 'bar', 'item', 'Value');
global $array;
for ($i = 0; $i < $iterations; ++$i) {
if ((array) $array == $array) {}
}
if ((array) $array == $array);
}
function gettypeArray()
{
$iterations = 100000;
$array = array('foo' => 'bar', 'item', 'Value');
global $array;
for ($i = 0; $i < $iterations; ++$i) {
if (gettype($array) == "array") {}
}
if (gettype($array) == "array");
}
isArray();
castArray();
gettypeArray();
for ($i = 0; $i < 100000; $i++) {
isArray();
castArray();
gettypeArray();
}

Binary file not shown.

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();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

@ -4,7 +4,7 @@ function implodeArr()
$string = '';
$array = array();
for ($i = 0; $i < 100000; ++$i) {
for ($i = 0; $i < 100; ++$i) {
$array[] = 'MyLittlePony != 42 ';
}
@ -15,7 +15,7 @@ function classic()
{
$string = '';
for ($i = 0; $i < 100000; ++$i) {
for ($i = 0; $i < 100; ++$i) {
$string .= 'MyLittlePony != 42 ';
}
}
@ -24,11 +24,13 @@ function reDefinition()
{
$string = '';
for ($i = 0; $i < 100000; ++$i) {
for ($i = 0; $i < 100; ++$i) {
$string == $string.'MyLittlePony != 42 ';
}
}
implodeArr();
classic();
reDefinition();
for ($i = 0; $i < 100000; $i++) {
implodeArr();
classic();
reDefinition();
}

Binary file not shown.

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();
}

Binary file not shown.

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();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Loading…
Cancel
Save