Skip to content

Commit

Permalink
made /profiler/method-used-apps.json compatible to phpstorm plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
shagtv committed Jan 31, 2020
1 parent 675429f commit b4c3aaa
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

There are next changes:

## 1.2.17

There are next changes:

- made /profiler/method-used-apps.json compatible to phpstorm plugin

## 1.2.16

There are next changes:
Expand Down
31 changes: 30 additions & 1 deletion src/www/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,37 @@

/** @var \Badoo\LiveProfilerUI\Pages\AjaxPages $Page */
$Page = $App->getPage('ajax_pages');
$method_data = $Page->getMethodUsedApps($method);

echo json_encode($Page->getMethodUsedApps($method));
$result = [];
if ($method_data) {
foreach ($method_data as $item) {
if (empty($item['fields']) || empty($item['fields']['calls_count'])) {
continue;
}

$item['cpu'] = $item['fields']['cpu'] / 1000;
$item['ct'] = $item['fields']['ct'];
$item['calls_count'] = (int)$item['fields']['calls_count'];
unset($item['fields']);
// Keep 1 app with maximum cpu
if (isset($result[$item['app']]) && $result[$item['app']]['cpu'] > $item['cpu']) {
continue;
}
$result[$item['app']] = $item;
}

uasort(
$result,
static function ($a, $b) {
return $b['cpu'] <=> $a['cpu'];
}
);

$result = array_values($result);
}

echo json_encode($result);
break;

case '/profiler/all-methods.json':
Expand Down

0 comments on commit b4c3aaa

Please sign in to comment.