几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » DirectDWG
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-05-05, 10:28 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】export very slow

export very slow
export very slow
hallo,
i have modified the odwriteex example to export only 20000 polys with 10
random vertex2d to show the speed problem. what is the problem wahat can i do.
to wait about 15 minute to export only 20000 polygon is not good. 20000 mtext
is much faster.
i hope anyone can help me.
thanks
stefan fink
dbfiller::filldatabase(oddbdatabase* pdb) {
....
oddblayertableptr players;
oddblayertablerecordptr player;
oddbobjectid pobjectid;
// modelspace holen und alle cad-objekte darin erzeugen
oddbblocktablerecordptr pms = pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
// layer table smart pointer, opened for read.
players = pdb->getlayertableid().safeopenobject(oddb::kforwrite) ;
player = oddblayertablerecord::createobject();
// name must be set before a table object is added to a table.
player->setname("hugo");
// add the object to the table.
oddbobjectid layerid = players->add(player);
oddb2dpolylineptr p2dpl = oddb2dpolyline::createobject();
oddb2dvertexptr pv;
pobjectid = pms->appendoddbentity(p2dpl);
p2dpl->setlayer(layerid, true);
for(int ii=1;ii<=20000;ii++) {
for(int jj=1;jj<=10;jj++) {
pv = oddb2dvertex::createobject();
oddbobjectid pvertexid= p2dpl->appendvertex(pv);
pv->setlayer(layerid, true);
odgepoint3d pos;
pos.x = ii*jj;
pos.y = ii*jj;
pos.z = 0;
pv->setposition(pos);
pv->setstartwidth(1);
pv->setendwidth(1);
}
}
...
if (pdb->gettilemode()) //model space
{
...
}
hi,
if your problem is in release mode and not in debug mode then probably you need to call pdb->starttransaction and pdb->endtransaction to optimize the undo/redo recording.
best regards
chudomir
hallo,
sorry but what is debug or release mode ??? !!! you meen with debug info or not ??
or can i toggle it on or off with methode !! ??
i only change the odwriteex example from the lib not more!
i need no undo or redo -- can i disable it !!???
sorry for the stupid questions !!
sorry for being unclear.
i meant to compile in debug or release mode - do you use visual studio to run the example? compiling in release would also switch to the release version of the dwgdirect libraries which are much faster. release does not mean only the missing of the debug info, but also optimizations, code minimization, etc.
as to the undo/redo - even if you don't need undo, please add the following lines (the ones in red):
pdb->starttransaction();
// modelspace holen und alle cad-objekte darin erzeugen
oddbblocktablerecordptr pms = pdb->getmodelspaceid().safeopenobject(oddb::kforwrit e) ;
// layer table smart pointer, opened for read.
players = pdb->getlayertableid().safeopenobject(oddb::kforwrit e) ;
player = oddblayertablerecord::createobject();
// name must be set before a table object is added to a table.
player->setname("hugo");
// add the object to the table.
oddbobjectid layerid = players->add(player);
oddb2dpolylineptr p2dpl = oddb2dpolyline::createobject();
oddb2dvertexptr pv;
pobjectid = pms->appendoddbentity(p2dpl);
p2dpl->setlayer(layerid, true);
for(int ii=1;ii<=20000;ii++) {
for(int jj=1;jj<=10;jj++) {
pv = oddb2dvertex::createobject();
oddbobjectid pvertexid= p2dpl->appendvertex(pv);
pv->setlayer(layerid, true);
odgepoint3d pos;
pos.x = ii*jj;
pos.y = ii*jj;
pos.z = 0;
pv->setposition(pos);
pv->setstartwidth(1);
pv->setendwidth(1);
}
}
pdb->endtransaction();
to disable the undo recording, simply add the call
pdb->disableundorecording(true); in the beginning. it can save some memory, but the start and endtransaction should do the work...
hope this helps.
best regards
chudomir
hallo,
this change nothing. i have attached my makefile an my changed dbfiller.cpp the rest is same as in the lib. can anyone test this on windows. we work on linux. but i think this must be same as on windows.
odwriteex.cpp
....
odstring sname;
odwrfilebuf fb(argv[1]);
// create & initialize a default database.
oddbdatabaseptr pdb = svcs.createdatabase();
pdb->disableundorecording(true);
pdb->starttransaction();
dbfiller filler;
filler.filldatabase(pdb);
pdb->endtransaction();
...
attached files (16.9 kb, 5 views)

wait a second - are you creating 20 000 plines with 10 vertices each or one polyline with 200 000 vertices?
or(int ii=1;ii<=20000;ii++) {
or(int jj=1;jj<=10;jj++) {
pv = oddb2dvertex::createobject();
oddbobjectid pvertexid= p2dpl->appendvertex(pv);
pv->setlayer(layerid, true);
odgepoint3d pos;
pos.x = ii*jj;
pos.y = ii*jj;
pos.z = 0;
pv->setposition(pos);
pv->setstartwidth(1);
pv->setendwidth(1);
}
best regards
chudomir
hallo,
yes. but this not very much. we have customers which have 100000 elements (polygon,
text, dimension) per dwg/dxf file.
i agree 100 000 entities are normal for some types of drawings, but we're talking about 1 polyline with 200 000 vertices! it surely cannot be a valid drawing...
is it so slow with 20 000 polylines with 10 vertices each?
best regards
chudomir
hallo,
ok the exact numbers are :
17372 elements
13859 polygons with 170861 points
3467 text
46 dimension with associtivity to 150 points
is only one example.
ok, so can you simply fix your test to be for 20 000 polylines with 10 verts each and not for 1 polyline with 200 000 vertices?
best regards
chudomir
170861 points / 13859 elements = 12,333 .. ca. points per element
what is wrong ???
example was 20000 elements each with 10 points !!! ???
stefan, i'm really sorry if i'm wrong but in your example you create only one polyline:
dbfiller::filldatabase(oddbdatabase* pdb) {
....
oddblayertableptr players;
oddblayertablerecordptr player;
oddbobjectid pobjectid;
// modelspace holen und alle cad-objekte darin erzeugen
oddbblocktablerecordptr pms = pdb->getmodelspaceid().safeopenobject(oddb::kforwrit e) ;
// layer table smart pointer, opened for read.
players = pdb->getlayertableid().safeopenobject(oddb::kforwrit e) ;
player = oddblayertablerecord::createobject();
// name must be set before a table object is added to a table.
player->setname("hugo");
// add the object to the table.
oddbobjectid layerid = players->add(player);
this one should be in the first loop and not outside it:
oddb2dpolylineptr p2dpl = oddb2dpolyline::createobject();
oddb2dvertexptr pv;
pobjectid = pms->appendoddbentity(p2dpl);
p2dpl->setlayer(layerid, true);
for(int ii=1;ii<=20000;ii++) {
// should be here!
for(int jj=1;jj<=10;jj++) {
pv = oddb2dvertex::createobject();
oddbobjectid pvertexid= p2dpl->appendvertex(pv);
pv->setlayer(layerid, true);
odgepoint3d pos;
pos.x = ii*jj;
pos.y = ii*jj;
pos.z = 0;
pv->setposition(pos);
pv->setstartwidth(1);
pv->setendwidth(1);
}
}
best regards
chudomir
hallo,
ok you are right. but this change nothing in the speed.
...
pdb->disableundorecording(true);
pdb->starttransaction();
pdb->settilemode(1); // 0 for paperspace, 1 for modelspace
// add a new regapp
addregapp(pdb, "oda");
oddblayertableptr players;
oddblayertablerecordptr player;
oddbobjectid pobjectid;
oddb2dvertexptr pv;
// modelspace holen und alle cad-objekte darin erzeugen
oddbblocktablerecordptr pms = pdb->getmodelspaceid().safeopenobject(oddb::kforwrite) ;
// layer table smart pointer, opened for read.
players = pdb->getlayertableid().safeopenobject(oddb::kforwrite) ;
player = oddblayertablerecord::createobject();
// name must be set before a table object is added to a table.
player->setname("hugo");
// add the object to the table.
oddbobjectid layerid = players->add(player);
for(int ii=1;ii<=20000;ii++) {
oddb2dpolylineptr p2dpl = oddb2dpolyline::createobject();
p2dpl->setlayer(layerid, true);
pobjectid = pms->appendoddbentity(p2dpl);
for(int jj=1;jj<=10;jj++) {
pv = oddb2dvertex::createobject();
oddbobjectid pvertexid= p2dpl->appendvertex(pv);
pv->setlayer(layerid, true);
odgepoint3d pos;
pos.x = ii*jj;
pos.y = ii*jj;
pos.z = 0;
pv->setposition(pos);
pv->setstartwidth(1);
pv->setendwidth(1);
}
}
pdb->endtransaction();
1 polyline with 200 000 points is not a valid example to measure...
best regards
chudomir
ok, let me run your code in our application to check the speed.
best regards
chudomir
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】slow performance with my dual xeon quad cores yang686526 SolidWorks二次开发 0 2009-04-13 02:22 PM


所有的时间均为北京时间。 现在的时间是 12:41 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多