iLogic - Runtime rules just after opening document 7x slower than 2, 3, enz. run
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
We are migrating from Inventor 2017 to 2021. We have built the 2021 templates and design data from scratch up.
Also made some changes to the iLogic rules we used. All fine so far.
Now we are performing speedtest compairation from 2017 to 2021. And we discoverd a huge difference in run time from the iLogic. Whe have discoverd that it is the first time a rule is runned in a part / assembly that it takes up to 7 times the runtime in compairation to the second or third time the rule is triggerd. When we close the part / assemby and open it. The first runtime is also 7 times slower. Same results.
This is the same in Inventor 2020.
In Inventor 2017 the difference is around 2x.
Is this a known issue?
We have scriped a performance test tool which does not include storage time. So we are logging only the time it takes to run the rule.
Class BOMiLogicRules 'Global variabelen Dim RuleName As String = "Performance Test" Dim oDoc As Document Dim oStopwatch As System.Diagnostics.Stopwatch = New System.Diagnostics.Stopwatch Sub Main() oDoc = ThisDoc.Document If oDoc.IsModifiable = False Then Return 'is Read-only End If Dim oTransaction As Transaction = ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument, oDoc.FullFileName.ToString.Split("\").Last.Split(".").First & ": " & RuleName) 'Start a transaction (Combines everything in single command, and therefore a single undo command as well) Logger.Info("Run Rule: " & oDoc.FullFileName.ToString.Split("\").Last.Split(".").First & ": " & RuleName & " " & DateTime.Now) Try Dim Iterations_Part As Integer = 1 Dim Iterations_Assembly As Integer = 1
Assembly_Save(Iterations_Assembly) Catch oException As Exception Logger.Error("Message: " & oException.Message) Logger.Error("HelpLink: " & oException.HelpLink) Logger.Error("Source: " & oException.Source) Logger.Error("StackTrace: " & oException.StackTrace) Logger.Error("TargetSite: " & oException.TargetSite.ToString) oTransaction.Abort() 'Abort transaction and undo everything Return End Try oTransaction.End() 'End the transaction End Sub
Sub Assembly_Save(ByVal Iterations As Integer) Dim TotalElapsedMilliseconds As Integer = 0 For i = 1 To Iterations Step 1 For Each xDoc As Document In oDoc.AllReferencedDocuments If xDoc.IsModifiable = True Then xDoc.PropertySets.Item("Inventor Summary Information").Item("Comments").Value = i End If Next oStopwatch.Restart For Each xDoc As Document In oDoc.ReferencedDocuments xDoc.Save() Next oStopwatch.Stop TotalElapsedMilliseconds += oStopwatch.ElapsedMilliseconds logger.info("RunRule: " & oiLogicRuleName & " // " & oStopwatch.ElapsedMilliseconds) Next logger.info("Result: /rule:" & oiLogicRuleName & " /iterations:" & Iterations & " /avg:" & Math.Round(TotalElapsedMilliseconds / Iterations, 0) & "ms") End Sub End Class
Whe have also made a test assembly from Inventor 2021 default templates. 10 parts, and add two iLogic rules each part:
1 Before Save
1 After Save
The rules are empty exept a logger info so we can see that the rule has runned on a part.
logger.Info("Hello After Save" & iProperties.Value("Project", "Part Number"))
Also than it takes up to 7 times more runtime for the first run after opening a document.
First run 2021:
INFO| 91: >>---------------------------
INFO|Run Rule: Assembly1: Performance Test 24-3-2021 09:32:37
INFO|Hello Before Save Part10
INFO|Hello After Save Part10
INFO|Hello Before Save Part9
INFO|Hello After Save Part9
INFO|Hello Before Save Part8
INFO|Hello After Save Part8
INFO|Hello Before Save Part7
INFO|Hello After Save Part7
INFO|Hello Before Save Part6
INFO|Hello After Save Part6
INFO|Hello Before Save Part5
INFO|Hello After Save Part5
INFO|Hello Before Save Part4
INFO|Hello After Save Part4
INFO|Hello Before Save Part3
INFO|Hello After Save Part3
INFO|Hello Before Save Part2
INFO|Hello After Save Part2
INFO|Hello Before Save Part1
INFO|Hello After Save Part1
INFO|RunRule: // 4638
INFO|Result: /rule: /iterations:1 /avg:4638ms
INFO| 92: >>---------------------------
Second run 2021:
INFO|Run Rule: Assembly1: Performance Test 24-3-2021 09:32:52
INFO|Hello Before Save Part10
INFO|Hello After Save Part10
INFO|Hello Before Save Part9
INFO|Hello After Save Part9
INFO|Hello Before Save Part8
INFO|Hello After Save Part8
INFO|Hello Before Save Part7
INFO|Hello After Save Part7
INFO|Hello Before Save Part6
INFO|Hello After Save Part6
INFO|Hello Before Save Part5
INFO|Hello After Save Part5
INFO|Hello Before Save Part4
INFO|Hello After Save Part4
INFO|Hello Before Save Part3
INFO|Hello After Save Part3
INFO|Hello Before Save Part2
INFO|Hello After Save Part2
INFO|Hello Before Save Part1
INFO|Hello After Save Part1
INFO|RunRule: // 628
INFO|Result: /rule: /iterations:1 /avg:628ms
