Skip to content

Commit

Permalink
feat(dom): add statistic info for dom size
Browse files Browse the repository at this point in the history
  • Loading branch information
ilikethese authored and hippy-actions[bot] committed Aug 24, 2023
1 parent 03c2442 commit 219e4a4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions dom/include/dom/root_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class RootNode : public DomNode {
void RemoveEvent(uint32_t id, const std::string& event_name);
void HandleEvent(const std::shared_ptr<DomEvent>& event) override;
void UpdateRenderNode(const std::shared_ptr<DomNode>& node);
uint32_t GetChildCount();

std::shared_ptr<DomNode> GetNode(uint32_t id);
std::tuple<float, float> GetRootSize();
Expand Down
9 changes: 9 additions & 0 deletions dom/src/dom/dom_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ void DomManager::CreateDomNodes(const std::weak_ptr<RootNode>& weak_root_node,
if (!root_node) {
return;
}
size_t create_size = nodes.size();
root_node->CreateDomNodes(std::move(nodes));
FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] create node size = " << create_size << ", total node size = " << root_node->GetChildCount();
}

void DomManager::UpdateDomNodes(const std::weak_ptr<RootNode>& weak_root_node,
Expand All @@ -85,7 +87,9 @@ void DomManager::UpdateDomNodes(const std::weak_ptr<RootNode>& weak_root_node,
if (!root_node) {
return;
}
size_t update_size = nodes.size();
root_node->UpdateDomNodes(std::move(nodes));
FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] update node size = " << update_size << ", total node size = " << root_node->GetChildCount();
}

void DomManager::MoveDomNodes(const std::weak_ptr<RootNode>& weak_root_node,
Expand All @@ -94,7 +98,9 @@ void DomManager::MoveDomNodes(const std::weak_ptr<RootNode>& weak_root_node,
if (!root_node) {
return;
}
size_t move_size = nodes.size();
root_node->MoveDomNodes(std::move(nodes));
FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] move node size = " << move_size << ", total node size = " << root_node->GetChildCount();
}

void DomManager::UpdateAnimation(const std::weak_ptr<RootNode>& weak_root_node,
Expand All @@ -112,7 +118,9 @@ void DomManager::DeleteDomNodes(const std::weak_ptr<RootNode>& weak_root_node,
if (!root_node) {
return;
}
size_t delete_size = nodes.size();
root_node->DeleteDomNodes(std::move(nodes));
FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] delete node size = " << delete_size << ", total node size = " << root_node->GetChildCount();
}

void DomManager::EndBatch(const std::weak_ptr<RootNode>& weak_root_node) {
Expand All @@ -125,6 +133,7 @@ void DomManager::EndBatch(const std::weak_ptr<RootNode>& weak_root_node) {
if (!root_node) {
return;
}
FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] total node size = " << root_node->GetChildCount();
root_node->SyncWithRenderManager(render_manager);
}

Expand Down
10 changes: 8 additions & 2 deletions dom/src/dom/layer_optimized_render_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ void LayerOptimizedRenderManager::CreateRenderNode(std::weak_ptr<RootNode> root_
nodes_to_create.push_back(node);
}
}

FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] create node size before optimize = " << nodes.size()
<< ", create node size after optimize = " << nodes_to_create.size();
if (!nodes_to_create.empty()) {
render_manager_->CreateRenderNode(root_node, std::move(nodes_to_create));
}
Expand Down Expand Up @@ -86,7 +87,8 @@ void LayerOptimizedRenderManager::UpdateRenderNode(std::weak_ptr<RootNode> root_
}
}
}

FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] update node size before optimize = " << nodes.size()
<< ", update node size after optimize = " << nodes_to_update.size();
if (!nodes_to_update.empty()) {
render_manager_->UpdateRenderNode(root_node, std::move(nodes_to_update));
}
Expand All @@ -108,6 +110,8 @@ void LayerOptimizedRenderManager::MoveRenderNode(std::weak_ptr<RootNode> root_no
}
}
}
FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] move node size before optimize = " << nodes.size()
<< ", move node size after optimize = " << nodes_to_move.size();
render_manager_->MoveRenderNode(root_node, std::move(nodes));
}

Expand All @@ -121,6 +125,8 @@ void LayerOptimizedRenderManager::DeleteRenderNode(std::weak_ptr<RootNode> root_
FindValidChildren(node, nodes_to_delete);
}
}
FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] delete node size before optimize = " << nodes.size()
<< ", delete node size after optimize = " << nodes_to_delete.size();
if (!nodes_to_delete.empty()) {
for (auto& node : nodes_to_delete) {
// Recursively delete all ids on the node tree.
Expand Down
6 changes: 6 additions & 0 deletions dom/src/dom/root_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ void RootNode::UpdateRenderNode(const std::shared_ptr<DomNode>& node) {
SyncWithRenderManager(render_manager);
}

uint32_t RootNode::GetChildCount() {
uint32_t child_count = 0;
Traverse([&child_count](const std::shared_ptr<DomNode>&) { child_count++; });
return child_count;
}

std::shared_ptr<DomNode> RootNode::GetNode(uint32_t id) {
if (id == GetId()) {
return shared_from_this();
Expand Down

0 comments on commit 219e4a4

Please sign in to comment.