Skip to content

Conversation

@yvonneyx
Copy link
Collaborator

@yvonneyx yvonneyx commented Dec 2, 2025

  • 搭建性能测试面板

以 @antv/[email protected] 作为基准,查看改造后的布局算法耗时情况。

image

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yvonneyx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此 PR 引入了一个全面的性能测试框架,旨在系统地评估图布局算法的性能。它通过集成新的测试脚本、配置和可视化仪表盘,实现了对不同布局算法在各种数据集规模下的基准测试。主要目标是监控和优化布局算法的执行效率,确保其在不同应用场景下的性能表现。

Highlights

  • 性能测试工具引入: 引入了新的性能测试脚本和配置,以支持对布局算法的性能评估。
  • 布局算法基准测试: 针对 CircularLayout、FruchtermanLayout、GridLayout 和 RandomLayout 引入了具体的性能测试,对比了开发版本与 @antv/[email protected] 基准版本在不同规模数据集上的表现。
  • 性能报告可视化: 添加了一个 HTML 仪表盘(perf/report-viewer.html),用于可视化性能测试结果,能够展示不同布局版本和规模的性能对比。
  • 数据集生成与管理: 包含了用于生成各种规模(从微型到超大型)随机集群数据集的工具,以及加载现有 G6 JSON 格式数据集的功能,为测试提供了丰富的数据源。
  • 开发依赖更新: 添加了 @antv/layout-npm 作为开发依赖,并将其别名为 @antv/[email protected],以便在性能测试中作为旧版本基准进行对比。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

这个 PR 在搭建性能测试框架方面做得非常出色,包括增加了测试工具、数据集和可视化的 Dashboard。这对于跟踪和比较不同布局算法的性能非常有帮助。

代码整体结构清晰,但仍有一些可以改进的地方:

  1. 代码重复:在多个 *.perf.ts 文件中,为不同规模数据集(tiny, small, ...)创建测试用例的代码高度重复。这可以通过工厂函数或循环来重构,以提高代码的可维护性。
  2. 可维护性report-viewer.html 文件中的 JavaScript 代码量较大,并且直接内嵌在 HTML 中。将其分离到独立的 JS 文件中会更易于管理。
  3. 健壮性:报告加载逻辑依赖于服务器的目录列表功能,这可能不稳定。使用清单文件是更可靠的替代方案。
  4. 类型安全:在一些工具函数中广泛使用了 any 类型,这削弱了 TypeScript 的类型检查优势。

总的来说,这是一次很棒的功能添加,上述建议旨在进一步提升代码质量。

Comment on lines +104 to +120
// Render edges
result.edges.forEach((edge) => {
const sourceNode: any = result.nodes.find((n) => n.id === edge.source);
const targetNode: any = result.nodes.find((n) => n.id === edge.target);
if (sourceNode && targetNode) {
const sourceX = sourceNode.data?.x || sourceNode.x;
const sourceY = sourceNode.data?.y || sourceNode.y;
const targetX = targetNode.data?.x || targetNode.x;
const targetY = targetNode.data?.y || targetNode.y;
ctx.beginPath();
ctx.moveTo(sourceX, sourceY);
ctx.lineTo(targetX, targetY);
ctx.strokeStyle = '#CCC';
ctx.lineWidth = 1;
ctx.stroke();
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

forEach 循环中为每条边调用 result.nodes.find 来查找源节点和目标节点,其时间复杂度为 O(N*M),其中 N 是节点数,M 是边数。对于大型图,这可能会很低效。建议在循环之前创建一个以节点 ID 为键的 Map,这样可以将查找时间复杂度降低到 O(1)。

  // Create a map for faster node lookup
  const nodeMap = new Map(result.nodes.map((node: any) => [node.id, node]));

  // Render edges
  result.edges.forEach((edge) => {
    const sourceNode: any = nodeMap.get(edge.source);
    const targetNode: any = nodeMap.get(edge.target);
    if (sourceNode && targetNode) {
      const sourceX = sourceNode.data?.x || sourceNode.x;
      const sourceY = sourceNode.data?.y || sourceNode.y;
      const targetX = targetNode.data?.x || targetNode.x;
      const targetY = targetNode.data?.y || targetNode.y;
      ctx.beginPath();
      ctx.moveTo(sourceX, sourceY);
      ctx.lineTo(targetX, targetY);
      ctx.strokeStyle = '#CCC';
      ctx.lineWidth = 1;
      ctx.stroke();
    }
  });

@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.72%. Comparing base (a9f7e70) to head (3bf999c).

Additional details and impacted files
@@           Coverage Diff           @@
##               v5     #265   +/-   ##
=======================================
  Coverage   80.72%   80.72%           
=======================================
  Files          70       70           
  Lines        4928     4928           
  Branches     1214     1209    -5     
=======================================
  Hits         3978     3978           
+ Misses        948      860   -88     
- Partials        2       90   +88     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yvonneyx yvonneyx merged commit ffacdc4 into v5 Dec 3, 2025
2 checks passed
@yvonneyx yvonneyx deleted the perf--init branch December 3, 2025 10:27
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.

3 participants