Just throwing another thought into the mix here. Since you may be running multiple iLogic rules across many documents, you could incorporate the use of SharedVariables into this project. As you may already know, they are a way to temporarily store data within Inventor's 'session memory'. Therefore that data you store that way will remain available as long as your Inventor session remains active, and you have not removed the data by using the SharedVariable.Remove() or SharedVariable.RemoveAll methods.
And another thought would be to use another iLogic rule as a starting point for running a series of other iLogic rules and/or VBA macros, but start your Stopwatch just before running that series of other rules, then stop the Stopwatch right after control returns to that top rule, then format the resulting time however best suits your needs, then write it to the iLogic Logger, or out to a more permanent external Log file. In my testing, the multi-rule accumulated time total seemed accurate. But keep in mind, that if you use interactive prompts, such as MsgBox, MessageBox.Show, InputBox, etc, those will allow elapsed time to keep counting while it is waiting on the user to respond, before moving forward with the remaining rule code, which can cause inaccuracies in recording true code processing time.
Here is a simple example of both ideas:
Dim oStopwatch As Stopwatch = Nothing
If SharedVariable.Exists("iLogic Stopwatch") Then
oStopwatch = SharedVariable.Value("iLogic Stopwatch")
Else
oStopwatch = New Stopwatch
End If
If Not oStopwatch.IsRunning Then oStopwatch.Start
'-----------------------------------------------------------------------------
'do some stuff here directly,
'or run multiple other rules/macros from here
'iLogicVb.RunRule("InternalRuleName1")
'iLogicVb.RunExternalRule("ExternalRuleName1")
'iLogicVb.RunMacro("ProjectName", "ComponentName", "MacroName")
'----------------------------------------------------------------------------
If oStopwatch.IsRunning Then oStopwatch.Stop
Dim oElapsed As TimeSpan = oStopwatch.Elapsed
Dim oTimeStr As String = oElapsed.Hours & " hrs " & oElapsed.Minutes & " min " _
& oElapsed.Seconds & " sec " & oElapsed.Milliseconds & " ms"
Logger.Info("Stopwatch Elapsed Time = " & oTimeStr)
SharedVariable.Value("iLogic Stopwatch") = oStopwatch
'or
'SharedVariable.Remove("iLogic Stopwatch")
Wesley Crihfield

(Not an Autodesk Employee)