Skip to content

Commit b4c3aaa

Browse files
committed
made /profiler/method-used-apps.json compatible to phpstorm plugin
1 parent 675429f commit b4c3aaa

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
There are next changes:
66

7+
## 1.2.17
8+
9+
There are next changes:
10+
11+
- made /profiler/method-used-apps.json compatible to phpstorm plugin
12+
713
## 1.2.16
814

915
There are next changes:

src/www/index.php

+30-1
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,37 @@
133133

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

137-
echo json_encode($Page->getMethodUsedApps($method));
138+
$result = [];
139+
if ($method_data) {
140+
foreach ($method_data as $item) {
141+
if (empty($item['fields']) || empty($item['fields']['calls_count'])) {
142+
continue;
143+
}
144+
145+
$item['cpu'] = $item['fields']['cpu'] / 1000;
146+
$item['ct'] = $item['fields']['ct'];
147+
$item['calls_count'] = (int)$item['fields']['calls_count'];
148+
unset($item['fields']);
149+
// Keep 1 app with maximum cpu
150+
if (isset($result[$item['app']]) && $result[$item['app']]['cpu'] > $item['cpu']) {
151+
continue;
152+
}
153+
$result[$item['app']] = $item;
154+
}
155+
156+
uasort(
157+
$result,
158+
static function ($a, $b) {
159+
return $b['cpu'] <=> $a['cpu'];
160+
}
161+
);
162+
163+
$result = array_values($result);
164+
}
165+
166+
echo json_encode($result);
138167
break;
139168

140169
case '/profiler/all-methods.json':

0 commit comments

Comments
 (0)