Accurate LotusScript timing technique

This tip describes and accurate method for timing LotusScript actions.

This Content Component encountered an error

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

Dig deeper on LotusScript

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close