About "Profiling agents and Web services"

** This blog is my first English text. I'm sorry if there is a mistake in the translation.

I was reading Help on Domino Designer and found unfamiliar features.
That is "Profiling agents and Web services". It seems like a feature introduced in version 7.0, but I never knew it.
As a result of reading the document, I became interested in this feature, so I will write about the results of various investigations.


The profiling agents feature reports on the following when an agent is written in LotusScript.
* The method of the Domino object used
* How many times was called
* Performance (execution time)

The following figure is an actual screenshot of profile results.

profile results

In this way, it is described separately for each object class and method.
The table is sorted in descending order of execution time, making it easier to understand where bottlenecks are in your programs.

you would be better to read help document this URL.
* but this site owner is IBM, you won't know when it will disappear.
Profiling agents and Web services

if you want to Japanese information, you would be better to read this site.
Lotus Domino 7エージェントプロファイル機能のご紹介

2.How to check profiling agents by agent’s property.

I will describe how to actually settings and check.

At first, the case of the agent.
(1) Open the agent written by LotusScript in Domino Designer.
(2) Open the agent properties.
(3) Check "Profile this agent" in Options.
Agent property
(4) Save the agent.
(5) Next, execute agent.
  * There is no problem with manual or scheduled execute.
  * The Notes application can be on the Domino server or on the Notes client.
(6) Right-click the agent in the agent view.
(7) Click '"View Profile Results" menu.

It is displayed the agent profiling results with this.
Profile results is saved as profile document in the Notes application. For that reason, only last exection results is saved. if you want to keep a record every time, save screen shots or copy and paste to Word documents.

3.How to check profiling agents by LotusScript.

The profile results can also be confirmed using LotusScript.
According to the help documentation, it is written to use GetPerformanceDocument of NotesAgent class.
using NotesAgent.GetPerformanceDocument, get profile document.
and, using NotesUIWorkspace.EditDocument, it displays on the screen.

4.About Extension feature

Actually, this feature enhanced in version 8.5.
It has been added method GetProfilerResults StartProfiler and StopProfiler into NotesSession class.
It can be profiling LotusScript code other than agents using these functions. you wrote the code directly script library or form, but isn't it working so slowly and not working as expected? It will be effective when used in such cases.
This profile document is saved as normal document in the Notes applications, not as a profile document.
For that reason, you can confirm the difference for every execute.

5.Sample code

I created sample code.
please refer to this code and execution results below.
There are 2 samples.
One is how to check agent's profile documents, the other one is about enhanced feature in version 8.5.

Sub Click(Source As Button)
  On Error Goto ErrProc
  Dim session As New NotesSession
  Dim db      As     NotesDatabase
  Dim agent   As     NotesAgent
  Dim doc     As     NotesDocument
  Dim uiws    As New NotesUIWorkspace
  Set db    = session.CurrentDatabase
  Set agent = db.GetAgent( "agtAgentAnalysisTest" )
  Call agent.Run()
  'Acquisition of profile result document and screen display
  Set doc = agent.GetPerformanceDocument()
  Call uiws.EditDocument( False, doc )
  Exit Sub
  Msgbox _
  "Error Line: "     & Cstr(Erl) & Chr$(10) & _
  "Error Number: "   & Cstr(Err) & Chr$(10) & _
  "Error Contents: " & Error, _
  0 + 16, "Agent Profile Test"
  Exit Sub
End Sub

Sub Click(Source As Button)
  On Error Goto ErrProc
  Dim session    As New NotesSession
  Dim dbProfile  As     NotesDatabase
  Dim docProfile As     NotesDocument
  Dim db         As     NotesDatabase
  Dim doc        As     NotesDocument
  Set dbProfile  = session.GetDatabase( "ServerName", "Notes Application Path", False )
  Set docProfile = dbProfile.CreateDocument()
  Call session.GetProfilerResults( docProfile, "Program Profile Result" )
  Call session.StartProfiler()
  '--- Code to be profiled---
  Set db      = session.CurrentDatabase
  Set doc     = db.CreateDocument
  Call doc.ReplaceItemValue( "Form", "fmMainTopic" )
  Call doc.ReplaceItemValue( "Subject", " Document created by agent " + Cstr(Now) )
  Call doc.Save( True, True, True )
  '--- Code to be profiled---
  Call session.StopProfiler()
  Call docProfile.Save( True, True, True )
  Exit Sub
  Msgbox _
  "Error Line: "     & Cstr(Erl) & Chr$(10) & _
  "Error Number: "   & Cstr(Err) & Chr$(10) & _
  "Error Contents: " & Error, _
  0 + 16, "Program Profile Test"
  Exit Sub
End Sub


Very few people around me knew about this feature.
I think it is because of the help documents and Domino Designer features.
Because the LotusScript mentioned above is not linked between Domino Desiger and help documents.
NotesSession.GetProfilerResults NotesSession. StartProfiler and NotesSession.StopProfiler appear in contents assistant, but they don't have a help document.

NotesSession class code assistant

NotesSession class help documentation
Conversely, NotesAgent.GetPerformanceDocument has a help documents, but don't appear in assistant contents.

GetPerformaceDocument method help documentation

NotesAgent class content assistant

This makes it difficult to use them correctly.
I hope that HCL will fix the documentation and modify Domino Designer.

That's all. thank you for reading.

HCL Masterの私が承ります!
お問い合わせはこちらから→Lotus Notes/Domino カスタマイズとセキュリティ強化 - 株式会社エフ