I think others have answered your exact question, but since you seem concerned about performance, I want to note that there are simpler ways to traverse an assembly in order. See the example "Traverse features in order using recursion" in the Macro Library section of my web site (requires a free membership).
I haven't tested to see whether this is more performant than the examples you linked to, but it is definitely simpler code and it works on all SolidWorks models instead of just assemblies.
38 seconds is dog slow unless you are doing a lot more than just traversing for basic info. You can traverse an assembly and its components and get that info in about 1 second.
Can you share your code? You can PM it if you dont want it public.
For speed issues, you are likely accessing lots of COM objects you don't need for your information, causing it to slow down. That can be cut down. Then if you are in VB.Net you may be calling it on the UI thread, causing every single call to go through a safe cast by SolidWorks back to the UI thread, every single COM call.
Also if it is out of process then it will be a little slower than an add-in so I would make it an add-in anyway, its really easy.
For example, BatchProcess has something called an Assembly Reporter than is an advanced BOM creator, that pulls all that same information. It generates HTML printable reports from assemblies with 500 components in about 1-2 seconds.
Thanks for your answers.
I think it because I created an outside .exe file instead of a .dll file.Now I use dll addin,it works well.
So say thanks to Keith again for offering me "Traverse features in order using recursion",it's what I want.