Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
4c43835e
Commit
4c43835e
authored
Feb 06, 2020
by
Dominik Hebeler
Browse files
added more timings
parent
84b24a24
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/MetaGerSearch.php
View file @
4c43835e
...
...
@@ -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
))
{
...
...
app/MetaGer.php
View file @
4c43835e
...
...
@@ -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
);
}
}
...
...
app/Models/Searchengine.php
View file @
4c43835e
...
...
@@ -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"
];
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment