Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optimize performance #6670

Merged
merged 4 commits into from
Dec 30, 2024
Merged

perf: optimize performance #6670

merged 4 commits into from
Dec 30, 2024

Conversation

Aarebecca
Copy link
Contributor

以 2W 元素为基准测试

优化前 1175 ms

整体时长缩短 361 ms (30%)

Copy link

Walkthrough

此PR通过优化多个方面的性能来提升整体效率。主要包括优化mergeOptions函数的性能,移除不必要的effect逻辑,以及关闭用例主题等。整体性能提升约30%。

Changes

文件 概述
packages/g6/tests/demos/perf-20000-elements.ts 更新节点样式,移除调色板,关闭主题。
packages/g6/src/elements/combos/base-combo.ts 移除effect相关逻辑。
packages/g6/src/elements/edges/base-edge.ts 移除effect相关逻辑。
packages/g6/src/elements/effect.ts 标记effect函数为废弃。
packages/g6/src/elements/nodes/base-node.ts 移除effect相关逻辑。
packages/g6/src/runtime/element.ts 移除动画相关的深拷贝逻辑。
packages/g6/src/utils/style.ts 优化mergeOptions函数的合并逻辑。

@@ -10,8 +10,10 @@ const EFFECT_WEAKMAP = new WeakMap<Element, Record<string, any>>();
* @param key - <zh/> 缓存 key | <en/> Cache key
* @param style - <zh/> 样式属性 | <en/> Style attribute
* @returns <zh/> 是否执行函数 | <en/> Whether to execute the function
* @deprecated <zh/> 该方法已废弃,并不能显著提升性能 | <en/> This method is deprecated and does not significantly improve performance

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

effect函数已被标记为废弃,建议彻底移除以避免误用。

@Aarebecca Aarebecca merged commit 9114eae into v5 Dec 30, 2024
2 checks passed
@Aarebecca Aarebecca deleted the perf/optimize branch December 30, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants