[PHP]
<?php

$timeList = array();
$testTitle  = array();
$testTitle [] = "\$a = time();";
$nb_occur=100000;
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
   $a = time();
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;
$refTime2=$time;
$testTitle [] = "\$a = sprintf('a %s', time());";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = sprintf('a %s', time());
}

$time_end = microtime(true);
$time = $time_end - $time_start;
$refTime3=$time;
$timeList[]=$time;

$testTitle [] = "\$a = str_replace('%s', time(), 'a %s');";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = str_replace('%s', time(), 'a %s');
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;


$testTitle [] = "\$a = strtr('a %s', array('%s'=> time() ));";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = strtr('a %s', array('%s'=> time() ));
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;


$testTitle [] = "\$a = str_replace('%t', time(), str_replace('%u', time(), str_replace('%s', time(), 'a %s %t %u'));";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = str_replace('%t', time(), str_replace('%u', time(), str_replace('%s', time(), 'a %s %t %u')));
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;


$testTitle [] = "\$a = str_replace(array('%t','%u','%s'), array(time(),time(),time(),), 'a %s %t %u');";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{

    $a = str_replace(array('%t','%u','%s'), array(time(),time(),time(),), 'a %s %t %u');
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;


$testTitle [] = "\$a = strtr('a %s %t %u', array('%s'=> time(), '%t'=> time(), '%u'=> time(), ));";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = strtr('a %s %t %u', array('%s'=> time(), '%t'=> time(), '%u'=> time(), ));
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;



$testTitle [] = "\$a = 'hello';";
$nb_occur=100000;
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
   $a = 'hello';
}

$time_end = microtime(true);
$time = $time_end - $time_start;
$refTime1=$time;
$timeList[]=$time;

$testTitle [] = "\$a = sprintf('a %s', 'hello');";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = sprintf('a %s', 'hello');
}

$time_end = microtime(true);
$time = $time_end - $time_start;
$refTime4=$time;
$timeList[]=$time;

$testTitle [] = "\$a = str_replace('%s', 'hello', 'a %s');";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = str_replace('%s', 'hello', 'a %s');
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;


$testTitle [] = "\$a = strtr('a %s', array('%s'=> 'hello' ));";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = strtr('a %s', array('%s'=> 'hello' ));
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;


$testTitle [] = "\$a = str_replace('%t', 'hello', str_replace('%u', 'hello', str_replace('%s', 'hello', 'a %s %t %u'));";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = str_replace('%t', 'hello', str_replace('%u', 'hello', str_replace('%s', 'hello', 'a %s %t %u')));
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;


$testTitle [] = "\$a = str_replace(array('%t','%u','%s'), array('hello','hello','hello',), 'a %s %t %u');";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = str_replace(array('%t','%u','%s'), array('hello','hello','hello',), 'a %s %t %u');
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;


$testTitle [] = "\$a = strtr('a %s %t %u', array('%s'=> 'hello', '%t'=> 'hello', '%u'=> 'hello', ));";
$time_start = microtime(true);
for ($i=0 ; $i<$nb_occur; $i++)
{
    $a = strtr('a %s %t %u', array('%s'=> 'hello', '%t'=> 'hello', '%u'=> 'hello', ));
}

$time_end = microtime(true);
$time = $time_end - $time_start;

$timeList[]=$time;


echo 'éxécuté '.$nb_occur.' fois <table border=1><tr><th>test<th>chrono secondes<th>ratio<br/>\'hello\'<th>ratio<br/>time()<th>ratio<br />sprintf(\'a %s\', time())<th>ratio<br/>sprintf(\'a %s\', \'hello\')</tr>';
foreach($timeList as $k=>$chrono)
{

    echo '<tr><td>' . $testTitle [$k]    
    . '<td>' 
    . sprintf('%01.5f',$chrono) 
    . '<td />' 
    . sprintf('%01.5f',$chrono/$refTime1) 
    . '<td />' 
    . sprintf('%01.5f',$chrono/$refTime2) 
        . '<td />' 
    . sprintf('%01.5f',$chrono/$refTime3) 
        . '<td />' 
    . sprintf('%01.5f',$chrono/$refTime4) 
    
    ;

}
echo '</table>';
?>