feat: 性能基准测试套件 — M3 里程碑起步
This commit is contained in:
@@ -2,6 +2,16 @@
|
||||
|
||||
## [0.9.0] — 2026-07-23
|
||||
|
||||
### M3 里程碑起步 — 性能基准测试套件
|
||||
- **新增 `bench/` 目录**:Google Benchmark 驱动的性能基准测试套件
|
||||
- **bench_bvh**:N=1K/10K/100K 随机三角形 SAH 构建 + 1K 射线最近命中查询
|
||||
- **bench_delaunay**:N=100/1K/10K 随机点 2D Bowyer-Watson 三角剖分
|
||||
- **bench_boolean**:两个球体 (N=100/500 面) 3D union/intersection 运算
|
||||
- **bench_curves**:N=10K/100K 次 Bezier/BSpline evaluate 吞吐量
|
||||
- **bench_spatial**:N=1K/10K/100K 点 R-Tree STR 构建 + KD-Tree 构建;kNN(n=10) 查询
|
||||
- **构建集成**:`BUILD_BENCHMARKS` 选项 (默认 OFF),Google Benchmark 通过 FetchContent 自动下载
|
||||
- **CTest 集成**:`ctest -R bench_` 一键运行全部基准
|
||||
|
||||
### Sprint 9 — 3D Delaunay/B-Rep/Boolean 测试补全
|
||||
- **测试新增**:test_delaunay_3d(6 个用例)、test_boolean_mesh(22 个用例)、test_brep(17 个用例)
|
||||
- **3D Delaunay 测试**:空输入、正四面体、Delaunay 空外接球性质验证、退化点(共面/共线)
|
||||
|
||||
@@ -5,6 +5,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
option(BUILD_TESTS "Build tests" ON)
|
||||
option(BUILD_BENCHMARKS "Build benchmarks" OFF)
|
||||
option(BUILD_EXAMPLES "Build examples" ON)
|
||||
option(ENABLE_SANITIZERS "Enable ASan" OFF)
|
||||
option(VDE_USE_GMP "GMP exact arithmetic" OFF)
|
||||
@@ -23,6 +24,10 @@ endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if(BUILD_BENCHMARKS)
|
||||
add_subdirectory(bench)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTS)
|
||||
enable_testing()
|
||||
find_package(GTest QUIET)
|
||||
|
||||
+8
-24
@@ -13,7 +13,6 @@
|
||||
#include <vde/brep/modeling.h>
|
||||
#include <vde/mesh/mesh_boolean.h>
|
||||
#include <vde/mesh/halfedge_mesh.h>
|
||||
#include <vde/core/transform.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace vde;
|
||||
@@ -25,34 +24,19 @@ struct SpherePair {
|
||||
mesh::HalfedgeMesh b;
|
||||
};
|
||||
|
||||
/// Create two intersecting spheres (sphere_a at (-0.5, 0, 0), sphere_b at (+0.5, 0, 0))
|
||||
SpherePair make_sphere_pair(int segments) {
|
||||
int seg_u = segments;
|
||||
int seg_v = std::max(segments / 2, 4);
|
||||
/// Create two intersecting spheres with approximately `face_count` faces each.
|
||||
/// sphere_a at origin, sphere_b translated by +1.0 along X (overlap ~0.5)
|
||||
SpherePair make_sphere_pair(int face_count) {
|
||||
// make_sphere produces ~ 2 * seg_u * seg_v faces → solve for seg
|
||||
int seg = std::max(static_cast<int>(std::ceil(std::sqrt(face_count / 2.0))), 4);
|
||||
int seg_u = seg;
|
||||
int seg_v = seg;
|
||||
|
||||
auto sphere_a = brep::make_sphere(1.0, seg_u, seg_v).to_mesh();
|
||||
auto sphere_b = brep::make_sphere(1.0, seg_u, seg_v).to_mesh();
|
||||
|
||||
// Translate sphere_b by +1.0 along X so they overlap by ~0.5
|
||||
core::Transform3D t;
|
||||
t.set_translation(core::Vector3D(1.0, 0.0, 0.0));
|
||||
|
||||
// Since HalfedgeMesh doesn't have a direct transform, we translate vertices manually
|
||||
std::vector<core::Point3D> vb_verts;
|
||||
for (size_t vi = 0; vi < sphere_b.num_vertices(); ++vi) {
|
||||
auto p = sphere_b.vertex(vi);
|
||||
vb_verts.push_back(core::Point3D(p.x() + 1.0, p.y(), p.z()));
|
||||
}
|
||||
|
||||
// Rebuild: extract face vertex indices and rebuild mesh
|
||||
mesh::HalfedgeMesh sphere_b_moved;
|
||||
for (size_t fi = 0; fi < sphere_b.num_faces(); ++fi) {
|
||||
auto fv = sphere_b.face_vertices(static_cast<int>(fi));
|
||||
sphere_b_moved.add_face(fv);
|
||||
}
|
||||
// Overwrite vertices (add_face adds them at original positions)
|
||||
// Actually we need a different approach — just vertex-move the existing mesh
|
||||
// Best: build directly from triangles
|
||||
// Rebuild from triangles with translated vertices
|
||||
mesh::HalfedgeMesh b_moved;
|
||||
std::vector<core::Point3D> all_verts;
|
||||
std::vector<std::array<int, 3>> all_tris;
|
||||
|
||||
+1
-1
@@ -42,5 +42,5 @@
|
||||
|--------|------|--------|
|
||||
| **M1: MVP** | ✅ 已完成 | 可编译工程 + 40 个头文件 + 核心实现 |
|
||||
| **M2: 功能完整** | ✅ 完成 | 所有模块实现完整、138 测试 100% 通过 |
|
||||
| **M3: 性能达标** | 📋 | 通过性能基准测试 |
|
||||
| **M3: 性能达标** | 🚧 进行中 | 通过性能基准测试 |
|
||||
| **M4: v1.0 发布** | 📋 | 稳定 API + 完整文档 + 示例教程 |
|
||||
|
||||
Reference in New Issue
Block a user