Commit 4c43835e authored by Dominik Hebeler's avatar Dominik Hebeler

added more timings

parent 84b24a24
......@@ -63,10 +63,7 @@ class MetaGerSearch extends Controller
# auf Ergebnisse warten und die Ergebnisse laden
$metager->createSearchEngines($request, $timings);
$metager->startSearch();
if (!empty($timings)) {
$timings["startSearch"] = microtime(true) - $time;
}
$metager->startSearch($timings);
$metager->waitForMainResults();
if (!empty($timings)) {
......
......@@ -632,11 +632,11 @@ class MetaGer
}
}
public function startSearch()
public function startSearch(&$timings)
{
# Wir starten alle Suchen
foreach ($this->engines as $engine) {
$engine->startSearch($this);
$engine->startSearch($this, $timings);
}
}
......
......@@ -105,12 +105,27 @@ abstract class Searchengine
{}
# Prüft, ob die Suche bereits gecached ist, ansonsted wird sie als Job dispatched
public function startSearch(\App\MetaGer $metager)
public function startSearch(\App\MetaGer $metager, &$timings)
{
if (!empty($timings)) {
$timings["startSearch"][$this->name]["start"] = microtime(true) - $timings["starttime"];
}
if ($this->canCache && Cache::has($this->hash)) {
if (!empty($timings)) {
$timings["startSearch"][$this->name]["checked cache"] = microtime(true) - $timings["starttime"];
}
$this->cached = true;
$this->retrieveResults($metager, true);
if (!empty($timings)) {
$timings["startSearch"][$this->name]["retrieved results"] = microtime(true) - $timings["starttime"];
}
} else {
if (!empty($timings)) {
$timings["startSearch"][$this->name]["checked cache"] = microtime(true) - $timings["starttime"];
}
// We need to submit a action that one of our workers can understand
// The missions are submitted to a redis queue in the following string format
// <ResultHash>;<URL to fetch>
......@@ -144,10 +159,17 @@ abstract class Searchengine
// Since each Searcher is dedicated to one specific search engine
// each Searcher has it's own queue lying under the redis key <name>.queue
Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission);
if (!empty($timings)) {
$timings["startSearch"][$this->name]["pushed job"] = microtime(true) - $timings["starttime"];
}
// The request is not cached and will be submitted to the searchengine
// We need to check if the number of requests to this engine are limited
if (!empty($this->engine->{"monthly-requests"})) {
Redis::incr("monthlyRequests:" . $this->name);
if (!empty($timings)) {
$timings["startSearch"][$this->name]["increased monthly requests"] = microtime(true) - $timings["starttime"];
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment