def single_pass_iter_3D_model(): from ezdxf.addons.iterdxf import single_pass_modelspace count = 0 for e in single_pass_modelspace(open(_3D_MODEL, 'rb')): e.dxftype() count += 1 print(f'Iterated {count} entities in modelspace (fanuc-430-arm.dxf).')
def entities1(filename): print('using single_pass_modelspace()') return single_pass_modelspace(open(filename, 'rb'))
t0 = time.perf_counter() doc = iterdxf.opendxf(BIGFILE) for entity in doc.modelspace(): counter[entity.dxftype()] += 1 doc.close() tb = time.perf_counter() - t0 print(f'Processing time: {tb:.2f}s') print(counter) print() name = 'iterdxf.single_pass_modelspace()' print(f"{name}\n{len(name) * '-'}") counter = Counter() t0 = time.perf_counter() for entity in iterdxf.single_pass_modelspace(open(BIGFILE, 'rb'), types=['LINE']): counter[entity.dxftype()] += 1 ta = time.perf_counter() - t0 print(f'Processing time: {ta:.2f}s') print(counter) print(f'Advantage {name}: {((tb / ta) - 1) * 100.:.0f}%\n') name = 'iterdxf.modelspace()' print(f"{name}\n{len(name) * '-'}") counter = Counter() t0 = time.perf_counter() for entity in iterdxf.modelspace(BIGFILE, types=['LINE']): counter[entity.dxftype()] += 1 tc = time.perf_counter() - t0
def entities1(filename): print("using single_pass_modelspace()") return single_pass_modelspace(open(filename, "rb"))