Tip

Accurate LotusScript timing technique

Have you ever wanted to do timing tests on your LotusScript code but found that NotesDateTime variables don't measure a small enough time interval? With NotesDateTime, you can only time to 100ths of a second. It's possible to get more accuracy by making system-dependant calls, but that ties the timing code to a particular OS. That could be a problem for you if your server is Unix, Linux, or AIX-based and your clients are all Wintel systems. Wouldn't it be nice if there was a system-independent way to time your code more accurately? Well, now there is.

There's a LotusScript function called GetThreadInfo that can get a variety of useful information for you. There's a trick to using this function, though. The key insight that made this code work is that I used numbers rather than the literal definitions (LSI_THREAD_TICKS etc.) listed in the help file. For some reason, if you use the literals, the code compiles, but fails when it runs (true for both R5 and ND6).


Here's the code:
**********************************************************
stc = Getthreadinfo(6) ' get the starting tick count

<the code you want to time>

ftc = Getthreadinfo(6) 'get the final tick count
tps = Getthreadinfo(7) 'get the ticks per second

t = (ftc - stc) / tps  'final tick count minus starting tick 
count divided by ticks per second yields duration.
**********************************************************

Here's a list of the OSes and Notes versions that this tip has been tested with. I'd like to thank Andrew Pollack of Northern Collaborative Technologies and Penumbra Group for their assistance with this testing. Note that AIX and Solaris systems will permit much finer measurements. One thousand ticks per second has been enough for all the testing I've done so far.

  • Win2000 Domino 6.0 (ticks per second 1000)
  • Win2000 Domino 5.0.9a (ticks per second 1000)
  • AIX 4.3.3 ML 9 with Domino 5.0.11 (ticks per second = 1,000,000)
  • Solaris 8 with Domino 5.0.11 (ticks per second = 1,000,000)
  • SuSE Linux 8.1 with Domino 6.0.1 (ticks per second 1000)
  • Server.Version.Notes = Release 6.0.1; Server.Version.OS = SunOS 5.8 Generic_108528-18 (ticks per second 1000)
stc = Getthreadinfo(6) 'get the 
starting tick count

<the code you want to time>

ftc = Getthreadinfo(6) 'get the final tick count
tps = Getthreadinfo(7) 'get the ticks per second

t = (ftc - stc) / tps  'final tick count minus starting 
tick count divided by ticks per second yields time.
  

This was first published in April 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.