perf: 给基础体构造加计时,定位到 DrawPipe/DrawCone/DrawLoft 共占 33%
继续追"剩余效率问题"。上一轮已确认 Parasolid 的 93.4% 发生在我们的视口绘制里, 本轮机位下一层:给 GiDrawUtility 的基础体构造函数加计时。 新增 inc/PerfCounterLite.h:header-only 的轻量计数器。 AecRxBase.arx 不链接 CoreLibrary(静态库只被 CoreCommand 链接),拿不到 SectionPerf 的符号,所以单独做一份;只在 Debug + AEC_PERF_COUNTER=1 时生效,Release 零开销。 统计写 %TEMP%\aec_prim_perf.txt(独立文件,避免提前写出 aec_section_perf.txt 让自动化脚本误判"开图完成")。 接入 GiDrawUtility:DrawPipe 三个重载、DrawLoft 两个重载、DrawCone、DrawCylinder。 实测(big1.dwg,93 s 开图 / 81 s CPU): DrawPipe(region) 7201 次 13.2 s 平均 1837us 最长 130ms DrawLoft(reg) 883 次 5.27 s 平均 5969us DrawLoft(curve) 883 次 5.90 s 平均 6679us DrawCone 811 次 4.64 s 平均 5717us DrawPipe(pts)/Cylinder 2411 次 4.07 s 平均 1688us 去重后约 27 s,占 81 s CPU 的 33%。 结论(详见 perf-primitive-cost.md): - 7201 次管道构建 vs 约 2260 个管类实体 = 3.2 次/实体,护栏/爬梯/设备细节也在造管道 - 单次成本差一个量级:圆柱 1.7ms 最便宜(已是优化过的快路径),圆锥 5.7ms、放样 6.0~6.7ms 最贵 - 长尾明显:DrawPipe 最长 130ms(平均的 70 倍),存在个别大件 - 都在"首次构建"路径上,没有重复重建,所以只能少建 / 建得更便宜 / 跨实体复用同参数几何 验证:R230 Debug 编译通过,tools/run_acad_perf.ps1 自动开图取数; 截面缓存与回写仍为正常/0(未受本次插桩影响)。
This commit is contained in:
1 parent
dd9b49e5a4
commit
47d7b96cad
3 files changed
+219
No files matched your search
@@ -1,5 +1,6 @@
|
||||
#include "StdAfx.h"
|
||||
#include "GiDrawutility.h"
|
||||
#include "PerfCounterLite.h"
|
||||
#include "EarThwormDef.h"
|
||||
|
||||
namespace
|
||||
@@ -262,6 +263,7 @@ AECDLLIMPEXP AcDbEntity* GiDrawUtility::DrawLoft(const AcDbRegion *pTop
|
||||
, const AcDbRegion *pBottom
|
||||
, const AcDbCurve *pLine)
|
||||
{
|
||||
perf_lite::Scope perfScope("GDU::DrawLoft(reg)");
|
||||
AcDbRegion *_pTop = (AcDbRegion*)pTop->clone();
|
||||
AcDbRegion *_pBottom = (AcDbRegion*)pBottom->clone();
|
||||
|
||||
@@ -297,6 +299,7 @@ AECDLLIMPEXP AcDbEntity* GiDrawUtility::DrawLoft(const AcDbCurve *pTop
|
||||
, const AcDbCurve *pBottom
|
||||
, const AcDbCurve *pLine)
|
||||
{
|
||||
perf_lite::Scope perfScope("GDU::DrawLoft(curve)");
|
||||
if (!pTop || !pBottom || !pLine) return NULL;
|
||||
|
||||
AcDbCurve *_pTop = (AcDbCurve*)pTop->clone();
|
||||
@@ -385,6 +388,7 @@ AECDLLIMPEXP AcDbEntity* GiDrawUtility::DrawCone(const AcGePoint3d &ptPos
|
||||
, const double &H
|
||||
, const double &xOffset)
|
||||
{
|
||||
perf_lite::Scope perfScope("GDU::DrawCone");
|
||||
AcGePoint3d ptBottom(AcGePoint3d::kOrigin);
|
||||
AcGePoint3d ptTop(ptBottom + xOffset * AcGeVector3d::kXAxis);
|
||||
ptTop.z = H;
|
||||
@@ -684,6 +688,7 @@ AECDLLIMPEXP AcDbEntity* GiDrawUtility::DrawCylinder(const AcGePoint3d &ptFr
|
||||
, const AcGePoint3d &ptTo
|
||||
, const double &dRadius)
|
||||
{
|
||||
perf_lite::Scope perfScope("GDU::DrawCylinder");
|
||||
return DrawPipe(ptFr, ptTo, dRadius, 0.);
|
||||
}
|
||||
|
||||
@@ -782,6 +787,7 @@ AcDbEntity* GiDrawUtility::DrawPipe(const AcGePoint3d& ptFrom
|
||||
, const double &dThick
|
||||
, const int &nSegs /*= 20*/)
|
||||
{
|
||||
perf_lite::Scope perfScope("GDU::DrawPipe(pts)");
|
||||
// 零长度路径无法扫掠
|
||||
if (EQUAL_ZERO(ptFrom.distanceTo(ptTo))) return NULL;
|
||||
|
||||
@@ -844,6 +850,7 @@ AcDbEntity* GiDrawUtility::DrawPipe(const AcDbCurve* pCurve
|
||||
|
||||
AcDbEntity* GiDrawUtility::DrawPipe(const AcDbCurve *pCurve, double dR)
|
||||
{
|
||||
perf_lite::Scope perfScope("GDU::DrawPipe(curve,dR)");
|
||||
if (!pCurve) return NULL;
|
||||
if (DOWNEQUAL_ZERO(dR)) return NULL;
|
||||
|
||||
@@ -940,6 +947,7 @@ AcDbEntity *GiDrawUtility::DrawPipe(
|
||||
, const AcDbRegion *pRegion
|
||||
, const AcGePoint3d &ptCenInRgn)
|
||||
{
|
||||
perf_lite::Scope perfScope("GDU::DrawPipe(region)");
|
||||
if (!pRegion || !pCurve) return NULL;
|
||||
|
||||
AcGePoint3d ptStart(AcGePoint3d::kOrigin);
|
||||
|
||||
Reference in new issue
Block a user