Tried to figure out which is the fastest iteration through a selection set - without actually doing anything. So used both the while & repeat loops on getting the dxf list (entget) as well as only the ename in preparation for
getpropertyvalue. Also added the vlax selection set iteration.
Testing on selection set of 1000 entities
Benchmarking ....... done for 1024 iterations. Sorted from fastest.
Statement Increment Time(ms) Normalize Relative
--------------------------------------------------------------------------------
(SSTEST_WHILEPROP) 1024 1029 1029 168.80
(SSTEST_REPEATPROP) 1024 1185 1185 146.58
(SSTEST_VLA) 256 1902 7608 22.83
(SSTEST_WHILEDXF) 128 1857 14856 11.69
(SSTEST_REPEATDXF) 128 1919 15352 11.31
(SSTEST_VLA_PROP) 16 1077 68928 2.52
(SSTEST_VLA_DXF) 8 1357 173696 1.00
--------------------------------------------------------------------------------
And compiled
Testing on selection set of 1000 entities
Benchmarking ....... done for 2048 iterations. Sorted from fastest.
Statement Increment Time(ms) Normalize Relative
--------------------------------------------------------------------------------
(SSTEST_REPEATPROP) 2048 1280 1280 284.00
(SSTEST_WHILEPROP) 2048 1577 1577 230.51
(SSTEST_VLA) 256 1888 15104 24.07
(SSTEST_WHILEDXF) 128 1794 28704 12.66
(SSTEST_REPEATDXF) 128 1809 28944 12.56
(SSTEST_VLA_PROP) 16 1075 137600 2.64
(SSTEST_VLA_DXF) 8 1420 363520 1.00
--------------------------------------------------------------------------------
It doesn't seem as if the difference between repeat & while is significant in comparison to what you actually do inside / outside the loop. As expected the convert from vla-object is simply stupidly slow (even with compiling). Pure VLA is about 2x faster than working with DXF data, but the ename only is 100x faster than that.
But that's only giving half the story. See what happens if I add a piece of code to each of the defuns. I'm adding a piece which extracts the Layer Name / LayerEname:
(getpropertyvalue en "LayerId") ;For the Prop defuns - returns the ename of the layer, not the layer name
Here's the test results
Testing on selection set of 1000 entities
Benchmarking ....... done for 64 iterations. Sorted from fastest.
Statement Increment Time(ms) Normalize Relative
--------------------------------------------------------------------------------
(SSTEST_WHILEDXF) 64 1202 1202 9.14
(SSTEST_REPEATDXF) 64 1233 1233 8.91
(SSTEST_VLA) 16 1154 4616 2.38
(SSTEST_WHILEPROP) 16 1700 6800 1.62
(SSTEST_REPEATPROP) 16 1701 6804 1.61
(SSTEST_VLA_PROP) 8 1372 10976 1.00
(SSTEST_VLA_DXF) 8 1373 10984 1.00
--------------------------------------------------------------------------------
_$ (vlisp-compile 'st "SelectTest.LSP")
T
_$ (load "SelectTest.FAS")
SSTEST_VLA_PROP
_$ (c:RunSSTest)
Testing on selection set of 1000 entities
Benchmarking ....... done for 128 iterations. Sorted from fastest.
Statement Increment Time(ms) Normalize Relative
--------------------------------------------------------------------------------
(SSTEST_WHILEDXF) 128 1918 1918 11.32
(SSTEST_REPEATDXF) 128 1950 1950 11.13
(SSTEST_VLA) 16 1139 9112 2.38
(SSTEST_REPEATPROP) 16 1606 12848 1.69
(SSTEST_WHILEPROP) 16 1654 13232 1.64
(SSTEST_VLA_DXF) 8 1342 21472 1.01
(SSTEST_VLA_PROP) 8 1357 21712 1.00
--------------------------------------------------------------------------------
See what I mean by it's more important about the internals of the loop than the loop itself? E.g. unexpectedly the dxf actually becomes faster than the vla - by 5x. And the prop becomes stupidly slow - nearly comparable to the converted defuns.