An error occurred while loading the file. Please try again.
-
llaffont authored
0.auteur - requete: 1.241854 - resultat: 1.84895 - retour: 1.156744 - total: 4.247548 + total: 2.449143 1.Millenium - requete: 0.393574 - resultat: 0.675219 - retour: 0.66293 - total: 1.731723 + total: 1.728375 2.France - requete: 0.87455 - resultat: 1.482955 - retour: 1.051353 - total: 3.408858 + total: 2.354162 3.Livre - requete: 3.895741 - resultat: 2.919363 - retour: 2.429558 - total: 9.244662 + total: 3.180693 4.loisirs - requete: 1.239962 - resultat: 1.172184 - retour: 1.282938 - total: 3.695084 + total: 8.41166 5.sports - requete: 3.146724 - resultat: 3.278857 - retour: 1.562699 - total: 7.98828 + total: 5.520501 6.jardin - requete: 1.043434 - resultat: 1.561235 - retour: 1.595568 - total: 4.200237 + total: 3.087021 7.informatique - requete: 0.444179 - resultat: 0.980564 - retour: 1.069331 - total: 2.494074 + total: 2.290389 8.univers - requete: 0.874648 - resultat: 1.673911 - retour: 1.681802 - total: 4.230361 + total: 2.463609 9.bouteille - requete: 0.7229 - res...
b180cb31
test_performance_recherche.php 2.76 KiB
<?php
error_reporting(E_ALL^E_DEPRECATED);
function old_recherche($expression_recherchee){
$cookie_file = tempnam("/tmp", "cookie");
$url_recherche = "http://web.afi-sa.net/pergame-enligne.net/recherche/simple";
// OLD recherche Step1 fill cookie
$curl_old_step_1 = curl_init($url_recherche);
curl_setopt($curl_old_step_1,CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($curl_old_step_1,CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($curl_old_step_1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_old_step_1,CURLOPT_POSTFIELDS, 'expressionRecherche='.$expression_recherchee);
curl_setopt($curl_old_step_1,CURLOPT_POST, true);
$result_old_step_1 = curl_exec($curl_old_step_1);
$temps_step_1 = curl_getinfo($curl_old_step_1,CURLINFO_TOTAL_TIME );
curl_close($curl_old_step_1);
// OLD recherche Step2 recherche/simple avec cookie
$curl_old_step_2 = curl_init($url_recherche);
curl_setopt($curl_old_step_2,CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($curl_old_step_2,CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($curl_old_step_2, CURLOPT_RETURNTRANSFER, true);
$result_old_step_2 = curl_exec($curl_old_step_2);
$temps_step_2 = curl_getinfo($curl_old_step_2,CURLINFO_TOTAL_TIME );
curl_close($curl_old_step_2);
if (false == strpos($result_old_step_2, 'Recherche : '.$expression_recherchee)) {
echo "Error\n";
}
echo "- requete: $temps_step_1\n";
echo "- resultat: $temps_step_2\n";
$total_time = $temps_step_1 + $temps_step_2;
echo "- total: $total_time\n";
return $total_time;
}
function new_recherche($expression_recherchee){
$cookie_file = tempnam("/tmp", "cookie");
$url_recherche = "http://opacce.pergame.net/opacce.pergame.net/recherche/simple/expressionRecherche/";
$curl_old_step_1 = curl_init($url_recherche.$expression_recherchee);
curl_setopt($curl_old_step_1,CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($curl_old_step_1,CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($curl_old_step_1,CURLOPT_RETURNTRANSFER, true);
$result_old_step_1 = curl_exec($curl_old_step_1);
$total_time = curl_getinfo($curl_old_step_1,CURLINFO_TOTAL_TIME );
curl_close($curl_old_step_1);
if (false == strpos($result_old_step_1, 'Recherche: '.$expression_recherchee)) {
echo "Error\n";
}
echo "+ total: $total_time\n";
return $total_time;
}
// main
$recherches = [
'auteur',
'Millenium',
'France',
'Livre',
'loisirs',
'sports',
'jardin',
'informatique',
'univers',
'bouteille',
'eau',
'telephone',
'Mac',
'Hercule',
'Emacs',
'Ordinateur',
'son',
'Millenium'];
$total_old = 0;
$total_new = 0;
foreach($recherches as $i => $expression) {
echo "$i.$expression\n";
$total_old = $total_old + old_recherche($expression);
$total_new = $total_new + new_recherche($expression);
}
echo "== TOTAL OLD: $total_old\n";
echo "== TOTAL NEW: $total_new\n";
?>