高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】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
|