diff --git a/CHANGELOG.md b/CHANGELOG.md index 7237dcc..05201fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ There are next changes: +## 1.1.2 + +There are next changes: + +- method list page was improved +- data on method list and tree pages are sorted now by the first param +- keep a graph period when go to a parent or child method + +## 1.1.1 + +There are next changes: + +- added a flame graph by params diff +- added a link to flame graph in the diff interface + ## 1.1.0 There are next changes: diff --git a/src/Badoo/LiveProfilerUI/Pages/FlameGraphPage.php b/src/Badoo/LiveProfilerUI/Pages/FlameGraphPage.php index b8bf703..8e69ebd 100644 --- a/src/Badoo/LiveProfilerUI/Pages/FlameGraphPage.php +++ b/src/Badoo/LiveProfilerUI/Pages/FlameGraphPage.php @@ -17,7 +17,7 @@ class FlameGraphPage extends BasePage { const MAX_METHODS_IN_FLAME_GRAPH = 3000; - const DEFAULT_THRESHOLD = 100; + const DEFAULT_THRESHOLD = 300; /** @var string */ protected static $template_path = 'flame_graph'; diff --git a/src/Badoo/LiveProfilerUI/Pages/ProfileMethodListPage.php b/src/Badoo/LiveProfilerUI/Pages/ProfileMethodListPage.php index ded9f7a..c5270b9 100644 --- a/src/Badoo/LiveProfilerUI/Pages/ProfileMethodListPage.php +++ b/src/Badoo/LiveProfilerUI/Pages/ProfileMethodListPage.php @@ -54,6 +54,7 @@ protected function cleanData() : bool $this->data['app'] = isset($this->data['app']) ? trim($this->data['app']) : ''; $this->data['label'] = isset($this->data['label']) ? trim($this->data['label']) : ''; $this->data['snapshot_id'] = isset($this->data['snapshot_id']) ? (int)$this->data['snapshot_id'] : 0; + $this->data['all'] = isset($this->data['all']) ? (bool)$this->data['all'] : false; if (!$this->data['snapshot_id'] && (!$this->data['app'] || !$this->data['label'])) { throw new \InvalidArgumentException('Empty snapshot_id, app and label'); @@ -82,7 +83,9 @@ public function getTemplateData() : array throw new \InvalidArgumentException('Can\'t get snapshot'); } - $all_fields = $this->FieldList->getAllFieldsWithVariations(); + $all_fields = $this->data['all'] ? + $this->FieldList->getAllFieldsWithVariations() : + $this->FieldList->getFields(); $fields = array_diff($this->FieldList->getFields(), [$this->calls_count_field]); $field_descriptions = $this->FieldList->getFieldDescriptions(); @@ -93,6 +96,7 @@ public function getTemplateData() : array foreach ($records as $Row) { /** @var \Badoo\LiveProfilerUI\Entity\MethodData $Row */ $values = $Row->getValues(); + $values = array_intersect_key($values, array_flip($all_fields)); foreach ($fields as $field) { $all_fields[$field . '_excl'] = $field . '_excl'; @@ -103,6 +107,8 @@ public function getTemplateData() : array $Row->setValues($values); } + $this->sortList($records); + $wall = $this->View->fetchFile( 'profiler_result_view_part', [ @@ -117,6 +123,17 @@ public function getTemplateData() : array return [ 'snapshot' => $Snapshot, 'wall' => $wall, + 'all' => $this->data['all'], ]; } + + protected function sortList(array &$records) + { + $sort_field = (string)current($this->FieldList->getFields()); + usort($records, function ($Element1, $Element2) use ($sort_field) : int { + /** @var \Badoo\LiveProfilerUI\Entity\MethodData $Element1 */ + /** @var \Badoo\LiveProfilerUI\Entity\MethodData $Element2 */ + return $Element2->getValue($sort_field) > $Element1->getValue($sort_field) ? 1 : -1; + }); + } } diff --git a/src/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePage.php b/src/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePage.php index eb0318a..1d3549c 100644 --- a/src/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePage.php +++ b/src/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePage.php @@ -127,7 +127,8 @@ public function getTemplateData() : array $common_block_data = [ 'link_base' => $link_base, 'fields' => $this->FieldList->getAllFieldsWithVariations(), - 'field_descriptions' => $this->FieldList->getFieldDescriptions() + 'field_descriptions' => $this->FieldList->getFieldDescriptions(), + 'stat_interval' => $this->data['stat_interval'], ]; $method_data = $this->getMethodDataWithHistory($date_to_snapshot_map, $this->data['method_id']); @@ -145,6 +146,7 @@ public function getTemplateData() : array $parents = $this->getMethodParentsWithHistory($date_to_snapshot_map, $this->data['method_id']); if (!empty($parents)) { + $this->sortList($parents); $view_data['parents'] = $this->View->fetchFile( 'profiler_result_view_part', $common_block_data + ['data' => $parents], @@ -154,6 +156,7 @@ public function getTemplateData() : array $children = $this->getMethodChildrenWithHistory($date_to_snapshot_map, $this->data['method_id']); if ($children) { + $this->sortList($children); $view_data['children'] = $this->View->fetchFile( 'profiler_result_view_part', $common_block_data + ['data' => $children, 'hide_lines_column' => true], @@ -166,6 +169,16 @@ public function getTemplateData() : array return $view_data; } + protected function sortList(array &$records) + { + $sort_field = (string)current($this->FieldList->getFields()); + usort($records, function ($Element1, $Element2) use ($sort_field) : int { + /** @var \Badoo\LiveProfilerUI\Entity\MethodData $Element1 */ + /** @var \Badoo\LiveProfilerUI\Entity\MethodData $Element2 */ + return $Element2->getValue($sort_field) > $Element1->getValue($sort_field) ? 1 : -1; + }); + } + protected function getMainMethodId() : int { $methods = $this->Method->findByName('main()', true); diff --git a/src/templates/profile_method_list.php b/src/templates/profile_method_list.php index c7742d8..ea29756 100644 --- a/src/templates/profile_method_list.php +++ b/src/templates/profile_method_list.php @@ -1,5 +1,6 @@ + @@ -86,6 +87,10 @@ #popover-target .disabled { color: #ddd; } + + .tablesorter-filter.disabled { + display: none; + } @@ -106,8 +111,152 @@
# | - -hide - - | - +# | + +hide + + | +name | - -= $param ?> - - | - + += $param ?> + + | +- - | - +- + + | + ++ = $MethodData->getMethodName() ?> | - -= $MethodData->getFormattedValue($param) ?> | - + += $MethodData->getFormattedValue($param) ?> | + - - diff --git a/src/www/index.php b/src/www/index.php index ac39357..80e3924 100644 --- a/src/www/index.php +++ b/src/www/index.php @@ -19,6 +19,7 @@ 'app' => isset($_GET['app']) ? trim($_GET['app']) : '', 'label' => isset($_GET['label']) ? trim($_GET['label']) : '', 'snapshot_id' => isset($_GET['snapshot_id']) ? (int)$_GET['snapshot_id'] : '', + 'all' => isset($_GET['all']) ? trim($_GET['all']) : '', ]; $Page = $App->getPage('profile_method_list_page'); echo $Page->setData($data)->render(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 6e0bc63..c36c6ac 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,2 +1,3 @@ disableOriginalConstructor() ->setMethods(['getValue']) ->getMock(); - $MethodTreeMock->method('getValue')->willReturn(200); + $MethodTreeMock->method('getValue')->willReturn(300); $data = []; for ($i = 0; $i < 3001; $i++) { $data[$i] = $MethodTreeMock; } return [ - ['data' => [], 'expected' => 100], - ['data' => $data, 'expected' => 200], + ['data' => [], 'expected' => 300], + ['data' => $data, 'expected' => 300], ]; } diff --git a/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodListPageTest.php b/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodListPageTest.php index 2ed8d83..3b4d18f 100644 --- a/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodListPageTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodListPageTest.php @@ -124,6 +124,7 @@ public function testGetTemplateData() 'app' => 'app', 'label' => 'label', 'snapshot_id' => 0, + 'all' => false, ]; /** @var \Badoo\LiveProfilerUI\Pages\ProfileMethodListPage $PageMock */ @@ -151,9 +152,10 @@ public function testGetTemplateData() 'wt_excl' => 'wt_excl' ], 'field_descriptions' => [], - 'link_base' => '/profiler/tree-view.phtml?app=app&label=label' + 'link_base' => '/profiler/tree-view.phtml?app=app&label=label', ], - 'snapshot' => $SnapshotEntityMock + 'snapshot' => $SnapshotEntityMock, + 'all' => false ]; static::assertEquals($expected, $result); } @@ -177,7 +179,8 @@ public function testCleanData() $expected = [ 'app' => 'app', 'label' => 'label', - 'snapshot_id' => 0 + 'snapshot_id' => 0, + 'all' => false ]; self::assertEquals($expected, $data); } diff --git a/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePageTest.php b/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePageTest.php index 91c492f..9be4039 100644 --- a/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePageTest.php +++ b/tests/unit/Badoo/LiveProfilerUI/Pages/ProfileMethodTreePageTest.php @@ -195,20 +195,23 @@ public function testGetTemplateData() 'fields' => ['wt' => 'wt', 'ct' => 'ct'], 'field_descriptions' => [], 'data' => [$MethodDataEntityMock], - 'hide_lines_column' => true + 'hide_lines_column' => true, + 'stat_interval' => 7 ], 'parents' => [ 'link_base' => '/profiler/tree-view.phtml?app=app&label=label', 'fields' => ['wt' => 'wt', 'ct' => 'ct'], 'field_descriptions' => [], 'data' => [$MethodTreeEntityMock], + 'stat_interval' => 7 ], 'children' => [ 'link_base' => '/profiler/tree-view.phtml?app=app&label=label', 'fields' => ['wt' => 'wt', 'ct' => 'ct'], 'field_descriptions' => [], 'data' => [$MethodTreeEntityMock], - 'hide_lines_column' => true + 'hide_lines_column' => true, + 'stat_interval' => 7 ], 'available_graphs' => [ 'wt' => [
---|