Profiling of LotusScript agents has been something that can be enabled for some time and I’ve long been a fan of it, blogging about it in 2011. Profiling was also something built into XPages Toolbox by Phil Riand. It’s also something I’ve built into RADAAR and my OSGi plugins in Java – just a simple Java timer function that logs to OpenLog. It’s helped identify bottlenecks in code and identify bugs where I’ve looped more than anticipated.

When I got my hands on the Domino V10 beta, I started applying new methods to ODA and cross-referencing with LotusScript to work out what the parameters are. The Java methods typically have parameter names arg0, arg1 etc. But LotusScript gives more usable parameter names, which can often help identify what needs to be passed. While looking at the new NotesSession methods I found three new methods in LotusScript which were not in Java – NotesSession.startProfiler(), NotesSession.stopProfiler() and NotesSession.getProfileResults(Output as NotesDocument, Title as String). These now allow developers to profile code that’s outside of an agent and save it to a profile document.

Here’s some sample code that iterates all entries in the “AllContacts” view in the Extension Library demo database and updates those whose state is Arizona. The profiler is started before the iteration and stopped at the end., and the results are stored in a new profile document withthetitle “Test Profiler”.

Sub Initialize
	Dim ws As New NotesUIWorkspace
	Dim s As New NotesSession
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim profileDoc As NotesDocument, doc As NotesDocument
	Set db = s.Currentdatabase
	Set profileDoc = db.Createdocument()
	Call s.Getprofilerresults(profileDoc, "Test Profiler")
	Call s.Startprofiler()
	Set view = db.Getview("AllContacts")
	Set doc = view.Getfirstdocument()
	While Not doc Is Nothing
		If doc.State(0) = "AZ" Then
			doc.isArizona = "Yes"
			Call doc.Save(True, False)
			doc.isArizona = "No"
		End If
		Set doc = view.Getnextdocument(doc)
	Call s.Stopprofiler()
	Call profileDoc.Save(True, False)
End Sub

The profile document created is the same kind of one that the agent profiler creates. The Form name is “$BEProfileR7”, the subject is the string title passed into the getProfilerResults() method and the body is the profile results. I haven’t worked out how to open the document yet. Obviously when you open the profile results by right-clicking an agent it somehow opens in that Form, which must be held somewhere in Notes. But opening the created document seems to expect that Form to be part of the design of the NSF which, obviously it isn’t. Hopefully someone can shed some light on that.

1 thought on “What’s New in Domino V10: LotusScript Profiling Extended”

  1. Have managed to open the document by editing the NotesDocument object used as parameter one in getprofileresults. It complained about the form not being available first time round, but worked after I had enabled profiling on one agent and then ran the agent once. This seemed to copy in a non-visible form into the database.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top