Reg Exp
Web Design
Notes Client
Keep track of how long an agent ran
When running a scheduled background agent in LotusScript, sometimes you may want to keep track of how long the agent's running. For example, if there are multiple ways to process documents (navigating through a view, building a collection, etc.) you could write the agent one way, keep timings on the agent for a period of time, then write the agent the other way and see which one on average is better.

If you place the following piece of code at the top and bottom of your agent, you will be able to keep track of how long (in seconds) the agent ran.

   Dim begintime As New NotesDateTime("")
   Dim endtime As New NotesDateTime("")
   Dim diff As Long
   Dim elapsedtime As String
   Call begintime.SetNow
   ' include agent code here
   Call endtime.SetNow
   diff = endtime.TimeDifference(begintime)
   elapsedtime = Format$(Timenumber (0,0,diff),"hh:nn:ss:")