Performance in an external process
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When testing or debugging code for an Inventor addin, I will often execute an external process that accesses the Inventor API. For an assembly containing 16000 nested components, simply traversing over each occurrence was taking 90 seconds.
Instead of calling ComponentOccurrence.SubOccurrences for each component, I found this time was reduced to 50 seconds if I only looked for occurrences within assemblies (i.e. first check that ComponentOccurrence.DefinitionDocumentType is DocumentTypeEnum.kAssemblyDocumentObject).
The execution time reduced to 8 seconds if I ran the code during the execute event handler for a button or change processor. I suspect this is due to API calls outside an event handler waiting for scheduled execution through the application message loop.
This is the F# code I used for testing.
let test (assembly : AssemblyDocument) = let rec loop (c : ComponentOccurrence) = if c.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject then for o in c.SubOccurrences do loop o
for o in assembly.ComponentDefinition.Occurrences do loop o
Timing
Without event handler and assembly check = 97.3 secs
Without event handler, with assembly check = 53.8 secs
With event handler, without assembly check = 20.1 secs
With event handler and assembly check = 8.5 secs
Now that the timing is more reasonable, I can continue with my intended performance test that compares repeatedly finding features in occurrences with finding a feature once and creating proxy features for other occurrences.
Regards,
cadull