Skip to content

Commit

Permalink
Analyse Moodle PERF logs - WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmuras committed Apr 20, 2020
1 parent dab82c8 commit 946d9ab
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions Moosh/Command/Generic/Report/PerfAnalyse.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,30 +138,47 @@ public function execute()
$this->save_csv('top5-requests-per-hour.csv', [$header], $top5hourscombined);

// Scripts by the database usage - which cause the most reads / writes.
$top5 = $this->get_by_metric("SUM(db_queries_time)", 5);
$top5calc = [];
$top5dbqueries = $this->get_by_metric("SUM(db_queries_time)", 5);
$top5dbqueriescalc = [];
echo "Top 5 scripts by the sum of DB queries time:\n";
foreach ($top5 as $topscript) {
foreach ($top5dbqueries as $topscript) {
echo "\t" . $topscript->script . "\t" . $topscript->total . "\n";

// Analyze single script in given $fromdate - $todate time frame.
$top5calc[] = $this->script_analyse($topscript->script, "SUM(db_queries_time)");
$top5dbqueriescalc[] = $this->script_analyse($topscript->script, "SUM(db_queries_time)");
}

// Number of requests per hour in one graph - 5 top scripts + the rest.
$hoursindex = $top5calc[0]->get_hours();
$hoursindex = $top5dbqueriescalc[0]->get_hours();
$top5hours = [];
foreach ($top5calc as $topcalc) {
foreach ($top5dbqueriescalc as $topcalc) {
$top5hours[] = $topcalc->get_hours();
}
$top5hourscombined = self::combine_arrays($top5hours, 'sum');
$header = [];
foreach ($top5 as $topscript) {
foreach ($top5dbqueries as $topscript) {
$header[] = $topscript->script;
}
$header = array_merge(['date'], $header);
$this->save_csv('top5-db-query-time-per-hour.csv', [$header], $top5hourscombined);

// Save each of the top 5 scripts with no of requests and DB usage columns.
// If they happen to be in both top 5 categories.
// Combine $top5calc and $top5dbqueriescalc.
$topall = [];
foreach ($top5 as $topcount) {
if (!isset($topall[$topcount->script])) {
$topall[$topcount->script] = ['header' => []];
}
$topall[$topcount->script];
}
foreach ($top5dbqueries as $topdb) {
$topall[$topdb->script] = true;
}

var_dump($topall);
$header = [];

// Scripts by the CPU usage.

// Entries that take the most time.
Expand Down

0 comments on commit 946d9ab

Please sign in to comment.