From 2a7b18f58f2b1a0d3fe68b72810f14f2193eba2f Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@afi-sa.fr>
Date: Fri, 2 Oct 2015 12:04:43 +0200
Subject: [PATCH] improve_search_performance

add monitoring script
---
 scripts/monitor_recherche.php | 36 +++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/scripts/monitor_recherche.php b/scripts/monitor_recherche.php
index 3e025b74c2a..7713cba0ffd 100644
--- a/scripts/monitor_recherche.php
+++ b/scripts/monitor_recherche.php
@@ -1,32 +1,48 @@
 <?php
 error_reporting(E_ALL^E_DEPRECATED);
 
-function new_recherche($expression_recherchee){
+if (!isset($argv[1])) {
+  echo 'I need bokeh URL !!';
+  exit(1);
+}
+
+
+function new_recherche($expression_recherchee, $url){
 	$cookie_file = tempnam("/tmp", "cookie");
-	$url_recherche = "http://opacce.pergame.net/opacce.pergame.net/recherche/simple/expressionRecherche/";    
+	$url_recherche = $url . '/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_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 date("H:i:s")." : $total_time s\n";
+	echo date("H:i:s")." : $total_time s  [$expression_recherchee]\n";
 	return $total_time;
 }
 
 
 // main
 while(true) {
-	foreach(['sport', 'france', 'pomme', 'informatique'] as $terme) {
-		new_recherche($terme);
+	foreach(['sport',
+           'france',
+           'pomme',
+           'informatique',
+           'plaine',
+           'poire',
+           'histoire',
+           'camille',
+           'mysql',
+           'ukulélé',
+           'minion',
+           'partition',
+           'musique',
+           'théatre',
+           'cinéma'] as $terme) {
+		new_recherche($terme, $argv[1]);
 		sleep(5);
 	}
 }
-- 
GitLab