I don't know if this is an apples to apples test but is interesting.
Add a line in an empty dwg and chose it
[CommandMethod("it")]
public void testEscape()
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptEntityResult per = ed.GetEntity("\nDon't pick a pline");
if (per.Status != PromptStatus.OK) return;
double start, now;
start = Convert.ToDouble(DateTime.Now.Ticks);
for(int i=0;i<1000;i++)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Polyline pline = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Polyline;
if (pline == null)
{
tr.Commit();
continue;
}
tr.Commit();
}
}
now = Convert.ToDouble(DateTime.Now.Ticks);
ed.WriteMessage("\nEllapsed time 1= 1" + ((now - start) / 10000.0).ToString());
start = Convert.ToDouble(DateTime.Now.Ticks);
for (int i = 0; i < 1000; i++)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Polyline pline = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Polyline;
if (pline == null) continue;
tr.Commit();
}
}
now = Convert.ToDouble(DateTime.Now.Ticks);
ed.WriteMessage("\nEllapsed time 2=" + ((now-start)/10000.0).ToString());
start = Convert.ToDouble(DateTime.Now.Ticks);
for (int i = 0; i < 1000; i++)
{
Transaction tr = db.TransactionManager.StartTransaction();
try
{
Polyline pline = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Polyline;
if (pline == null)
{
continue;
}
}
finally
{
tr.Dispose(); //implicit abort
}
}
now = Convert.ToDouble(DateTime.Now.Ticks);
ed.WriteMessage("\nEllapsed time 3=" + ((now - start) / 10000.0).ToString());
}
Ellapsed time 1= 162.5024
Ellapsed time 2=953.1392
Ellapsed time 3=953.1392
I saw an older post commit vs abort I think where Tony was using objectid.open for readonly but I couldn't figure out how to put that in the same test.
Practically the time difference for one or 2 iterations would never be worth the typing.