AcDbPolyline对象new与clone的效率差异

作者: admin 分类: C++,CAD,ObjectARX 发布时间: 2022-02-08 19:05

for(int i=0;i<10000;i++)

{

AcDbPolyline* pPoly = new AcDbPolyline(2);

pPoly->addVertexAt(0, ptstart,0, width_, width_);

pPoly->addVertexAt(1, ptend,0, width_, width_);

delete pPoly;

}

//—————————————————————————-

AcDbPolyline* pPoly = new AcDbPolyline(2);

pPoly->addVertexAt(0, ptstart,0, width_, width_);

pPoly->addVertexAt(1, ptend,0, width_, width_);

for(int i=0;i<10000;i++)

{

AcDbPolyline* pClonePoly = (AcDbPolyline*)pPoly->clone();

delete pClonePoly;

}

delete pPoly;

以上两个程序,用时分别为

1–>用时0.007384秒

1–>用时0.014807秒

也就是相差两倍的差距,合理吗?

标签云